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
Showing only changes of commit 68e32149cc - Show all commits

View File

@ -42,6 +42,10 @@ 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.')
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:
logger.error('An error occurred:', exc_info=True) # Log with stack trace
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)