ISEPOS-2280 Added base loggers scripts #1

3 changed files with 5 additions and 5 deletions
Showing only changes of commit 03616dcac6 - Show all commits

View File

@ -39,7 +39,7 @@
% logger.info('Some info') % logger.info('Some info')
% %
Outdated
Review

Can we put here an example with error object? So that the stack trace of the exception gets logged.

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.

Base logger has been enchanced and example for error logging has been added.
% try % try
% error('Simulated error for stack trace logging'); % % some code causing exception
% catch err % catch err
% logger.error('An error occurred:', err); % logger.error('An error occurred:', err);
% end % end

View File

@ -39,7 +39,7 @@
% logger.info('Some info') % logger.info('Some info')
% %
% try % try
% error('Simulated error for stack trace logging'); % % some code causing exception
% catch err % catch err
% logger.error('An error occurred:', err); % logger.error('An error occurred:', err);
% end % end

View File

@ -43,9 +43,9 @@ def getDefaultLogger(name):
logger = getDefaultLogger(__name__) logger = getDefaultLogger(__name__)
logger.info("This is an info message.") logger.info("This is an info message.")
Outdated
Review

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

Example for error with stack trace logging has been added.

Example for error with stack trace logging has been added.
try: try:
raise Exception('Exception for example.') # some code causing exception
Outdated
Review

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

Ok, I will do the same for Matlab and Octave versions.

Ok, I will do the same for Matlab and Octave versions.
except Exception as e: except Exception:
logger.error('An error occurred:', exc_info=True) # Log with stack trace logger.exception('An error occurred')
Outdated
Review

We have except Exception as e but the e is not used anywhere... is this correct?

We have `except Exception as e` but the `e` is not used anywhere... is this correct?

Maybe it is good to use here the logger.exception() (doc) method as a showcase.

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.

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().

`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) logger = logging.getLogger(name)