-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
766d365
commit 3fc39a4
Showing
17 changed files
with
264 additions
and
34 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
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
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,5 +1,6 @@ | ||
from .logging_config import LoggingConfig | ||
from .truncate_logging_filter import TruncateLoggingFilter | ||
from .newline_logging_filter import NewlineLoggingFilter | ||
from .json_formatter import JsonFormatter | ||
|
||
__all__ = ["LoggingConfig", "TruncateLoggingFilter", "NewlineLoggingFilter"] | ||
__all__ = ["LoggingConfig", "TruncateLoggingFilter", "NewlineLoggingFilter", "JsonFormatter"] |
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,19 @@ | ||
import json | ||
import logging | ||
from typing import Any | ||
|
||
from attrs import define, field | ||
|
||
|
||
@define | ||
class JsonFormatter(logging.Formatter): | ||
indent: int = field(default=2, kw_only=True) | ||
|
||
def __attrs_pre_init__(self) -> None: | ||
super().__init__() | ||
|
||
def format(self, record: Any) -> str: | ||
if isinstance(record.msg, dict): | ||
record.msg = json.dumps(record.msg, indent=self.indent) | ||
|
||
return super().format(record) |
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
Oops, something went wrong.