Skip to content

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 <omar.eissaanwar@gmail.com>

Signed-off-by: Omar Eissa <omar.eissaanwar@gmail.com>
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