For Log exception write to ERROR, add the stack trace too
This commit is contained in:
@@ -32,4 +32,6 @@ def jmespath_search(search_data: dict[Any, Any] | list[Any], search_params: str)
|
|||||||
raise ValueError(f"Type error for search_params: {excp}") from excp
|
raise ValueError(f"Type error for search_params: {excp}") from excp
|
||||||
return search_result
|
return search_result
|
||||||
|
|
||||||
|
# TODO: compile jmespath setup
|
||||||
|
|
||||||
# __END__
|
# __END__
|
||||||
|
|||||||
@@ -229,7 +229,8 @@ class LogParent:
|
|||||||
if log_error:
|
if log_error:
|
||||||
self.logger.log(
|
self.logger.log(
|
||||||
LoggingLevel.ERROR.value,
|
LoggingLevel.ERROR.value,
|
||||||
f"<=EXCEPTION> {msg}", *args, extra=dict(extra) | {'console': True}, stacklevel=2
|
f"<=EXCEPTION> {msg} [{extra['stack_trace']}]",
|
||||||
|
*args, extra=dict(extra) | {'console': True}, stacklevel=2
|
||||||
)
|
)
|
||||||
self.logger.log(LoggingLevel.EXCEPTION.value, msg, *args, exc_info=True, extra=extra, stacklevel=2)
|
self.logger.log(LoggingLevel.EXCEPTION.value, msg, *args, exc_info=True, extra=extra, stacklevel=2)
|
||||||
|
|
||||||
|
|||||||
52
test-run/json_handling/jmespath_helper.py
Normal file
52
test-run/json_handling/jmespath_helper.py
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
"""
|
||||||
|
jmes path testing
|
||||||
|
"""
|
||||||
|
|
||||||
|
from corelibs.debug_handling.dump_data import dump_data
|
||||||
|
from corelibs.json_handling.jmespath_helper import jmespath_search
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
"""
|
||||||
|
Comment
|
||||||
|
"""
|
||||||
|
__set = {
|
||||||
|
'a': 'b',
|
||||||
|
'foobar': [1, 2, 'a'],
|
||||||
|
'bar': {
|
||||||
|
'a': 1,
|
||||||
|
'b': 'c'
|
||||||
|
},
|
||||||
|
'baz': [
|
||||||
|
{
|
||||||
|
'aa': 1,
|
||||||
|
'ab': 'cc'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'ba': 2,
|
||||||
|
'bb': 'dd'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'foo': {
|
||||||
|
'a': [1, 2, 3],
|
||||||
|
'b': ['a', 'b', 'c']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__get = [
|
||||||
|
'a',
|
||||||
|
'bar.a',
|
||||||
|
'foo.a',
|
||||||
|
'baz[].aa'
|
||||||
|
]
|
||||||
|
for __jmespath in __get:
|
||||||
|
result = jmespath_search(__set, __jmespath)
|
||||||
|
print(f"GET {__jmespath}: {dump_data(result)}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
|
# __END__
|
||||||
Reference in New Issue
Block a user