-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from lifeomic/FLDM-390/json-child-logger
Add JsonLogger which supports child loggers
- Loading branch information
Showing
6 changed files
with
249 additions
and
100 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,3 +129,4 @@ dmypy.json | |
# Pyre type checker | ||
.pyre/ | ||
.idea | ||
.tool-versions |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to | ||
[Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.4.0] - 2024-10-11 | ||
|
||
### Added | ||
|
||
- Added a new `JsonLogger` class that logs messages in JSON format. Supports | ||
child loggers as well. The logger inherits from builtin `logging.Logger` and | ||
the log methods have the same API as the builtin as well. Example usage: | ||
|
||
```python | ||
from lifeomic_logging import JsonLogger | ||
|
||
# Create a logger with a name and optional context that will be included | ||
# on all log messages. | ||
logger = JsonLogger("my-logger", {"foo": "bar"}) | ||
logger.info({"msg": "message", "isTrue": True}) | ||
# >>> {"name": "my-logger", "foo": "bar", "level": "INFO", "msg": "message", "isTrue": true} | ||
child_logger = logger.child({"fizz": "buzz"}) | ||
child.info("message") | ||
# >>> {"name": "my-logger", "foo": "bar", "fizz": "buzz", "level": "INFO", "msg": "message"} | ||
``` |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.3.2" | ||
__version__ = "0.4.0" |
Oops, something went wrong.