Skip to content

Commit

Permalink
HH-199730 try use orjson for log dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
bokshitsky committed Nov 25, 2023
1 parent 1a39600 commit 2bcaf24
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
3 changes: 3 additions & 0 deletions frontik/loggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from logging.handlers import SysLogHandler
from typing import TYPE_CHECKING

import orjson
from tornado.log import LogFormatter

from frontik import request_context
Expand Down Expand Up @@ -90,6 +91,8 @@ def format(self, record):
if stack_trace:
json_message['exception'] = stack_trace

if options.log_use_orjson:
return orjson.dumps(json_message).decode("utf-8")
return json.dumps(json_message)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions frontik/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Options:

log_dir: str | None = None
log_level: str = 'info'
log_use_orjson: bool = True
update_log_level_interval_in_seconds: int = 300
log_json: bool = True
log_text_format: str = '[%(process)s] %(asctime)s %(levelname)s %(name)s: %(message)s'
Expand Down
63 changes: 61 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jinja2 = '3.1.2'
lxml = '4.9.2'
pydantic = '^2.3.0'
tornado = '6.3.2'
orjson = '*'
http-client = {git = 'https://github.com/hhru/balancing-http-client.git', tag = '2.1.4'}
python-consul2-hh = {git = 'https://github.com/hhru/python-consul2', tag = 'v0.2.9'}
opentelemetry-sdk = '1.17.0'
Expand Down

0 comments on commit 2bcaf24

Please sign in to comment.