Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LoggerFactory for structured logging #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

o-eissa
Copy link

@o-eissa o-eissa commented Jan 21, 2024

Fix #10

This PR introduces a new LoggerFactory class in factories.py. This class provides a method get_logger to create a logger with a custom format and behavior to output structured logs following the format in the Go sdk PR
Key features of the LoggerFactory class include:

  • The get_logger method, which creates a new logger with the specified name and log level. The log level defaults to logging.DEBUG if not provided and name to the default name logger.
  • A custom formatter LowerCaseLevelNameFormatter is used to convert the log level name to lowercase.
  • The log format includes the timestamp, log level, message, hostname, application name (filename), and line number.
  • The hostname is automatically populated using 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"}

@o-eissa o-eissa force-pushed the issue_10 branch 2 times, most recently from 2b9c0d6 to a05a96c Compare January 23, 2024 05:41
Fix project-alvarium#10
Signed-off-by: Omar Eissa <[email protected]>

Signed-off-by: Omar Eissa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement logging feature and format as in the Go SDK
1 participant