Add LoggerFactory for structured logging#11
Open
o-eissa wants to merge 1 commit intoproject-alvarium:mainfrom
Open
Add LoggerFactory for structured logging#11o-eissa wants to merge 1 commit intoproject-alvarium:mainfrom
o-eissa wants to merge 1 commit intoproject-alvarium:mainfrom
Conversation
2b9c0d6 to
a05a96c
Compare
Fix project-alvarium#10 Signed-off-by: Omar Eissa <omar.eissaanwar@gmail.com> Signed-off-by: Omar Eissa <omar.eissaanwar@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
LoggerFactoryclass infactories.py. This class provides a methodget_loggerto create a logger with a custom format and behavior to output structured logs following the format in the Go sdk PRKey features of the
LoggerFactoryclass include:get_loggermethod, which creates a new logger with the specified name and log level. The log level defaults tologging.DEBUGif not provided and name to the default name logger.LowerCaseLevelNameFormatteris 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"}