ISEPOS-2280 Added base loggers scripts #1
@ -42,6 +42,10 @@ def getDefaultLogger(name):
|
||||
--------
|
||||
logger = getDefaultLogger(__name__)
|
||||
logger.info("This is an info message.")
|
||||
|
||||
try:
|
||||
raise Exception('Exception for example.')
|
||||
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 as e:
|
||||
logger.error('An error occurred:', exc_info=True) # Log with stack trace
|
||||
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
An example with an error with logging stack trace would be convenient here
Example for error with stack trace logging has been added.