ISEPOS-2280 Added base loggers scripts #1

Open
ymlesni wants to merge 8 commits from ymlesni/shared-snippets:feature/ISEPOS-2280-mechanizm-raportowania-informacji-z-aplikacji-do-pliku-z-logami into main
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')
%
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
% error('Simulated error for stack trace logging');
% % some code causing exception
% catch err
% logger.error('An error occurred:', err);
% end

View File

@ -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

View File

@ -43,9 +43,9 @@ def getDefaultLogger(name):
logger = getDefaultLogger(__name__)
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:
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
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:
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)