Add LoggerFactory for structured logging #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #10
This PR introduces a new
LoggerFactory
class infactories.py
. This class provides a methodget_logger
to create a logger with a custom format and behavior to output structured logs following the format in the Go sdk PRKey features of the
LoggerFactory
class include:get_logger
method, which creates a new logger with the specified name and log level. The log level defaults tologging.DEBUG
if not provided and name to the default name logger.LowerCaseLevelNameFormatter
is used to convert the log level name to lowercase.socket.gethostname()
.Example:
{"timestamp":"2024-01-21T09:37:47Z","log-level": "debug","message":"sdk disposed","hostname":"DESKTOP-0QCUII1", "application":"default.py", "line-number":"default.py:63"}