ISEPOS-2280 Added base loggers scripts #1
@ -39,7 +39,7 @@
|
||||
% logger.info('Some info')
|
||||
%
|
||||
|
||||
% try
|
||||
% error('Simulated error for stack trace logging');
|
||||
% % some code causing exception
|
||||
% catch err
|
||||
% logger.error('An error occurred:', err);
|
||||
% end
|
||||
|
@ -39,7 +39,7 @@
|
||||
% logger.info('Some info')
|
||||
%
|
||||
% try
|
||||
% error('Simulated error for stack trace logging');
|
||||
% % some code causing exception
|
||||
% catch err
|
||||
% logger.error('An error occurred:', err);
|
||||
% end
|
||||
|
@ -43,9 +43,9 @@ def getDefaultLogger(name):
|
||||
logger = getDefaultLogger(__name__)
|
||||
logger.info("This is an info message.")
|
||||
asia
commented
An example with an error with logging stack trace would be convenient here An example with an error with logging stack trace would be convenient here
ymlesni
commented
Example for error with stack trace logging has been added. Example for error with stack trace logging has been added.
|
||||
try:
|
||||
raise Exception('Exception for example.')
|
||||
except Exception as e:
|
||||
logger.error('An error occurred:', exc_info=True) # Log with stack trace
|
||||
# some code causing exception
|
||||
asia
commented
Maybe just put here some placeholder meaning that this is a code that may produce an error Maybe just put here some placeholder meaning that this is a code that may produce an error
ymlesni
commented
Ok, I will do the same for Matlab and Octave versions. Ok, I will do the same for Matlab and Octave versions.
|
||||
except Exception:
|
||||
logger.exception('An error occurred')
|
||||
asia
commented
We have We have `except Exception as e` but the `e` is not used anywhere... is this correct?
h.siejkowski
commented
Maybe it is good to use here the Maybe it is good to use here the `logger.exception()` ([doc](https://docs.python.org/3/library/logging.html#logging.Logger.exception)) method as a showcase.
ymlesni
commented
`e` could be used to process exception further, but it is not necessary for example, I will remove it.
Would adding `logger.exception()` as a additional option be a good idea (to still showcase how to log exception at chosen log level)? For now I will change to `logger.exception()`.
|
||||
|
||||
"""
|
||||
logger = logging.getLogger(name)
|
||||
|
Loading…
Reference in New Issue
Block a user
Can we put here an example with error object? So that the stack trace of the exception gets logged.
Base logger has been enchanced and example for error logging has been added.