Skip to content

Commit

Permalink
Merge pull request #4236 from MJedr/refactor-handlers
Browse files Browse the repository at this point in the history
update logger settings
  • Loading branch information
MJedr authored Nov 14, 2022
2 parents 97df00b + babe14a commit 14a7fe8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
33 changes: 33 additions & 0 deletions inspirehep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""INSPIREHEP app configuration."""

from __future__ import absolute_import, division, print_function
from logging.config import dictConfig

import os
import sys
Expand Down Expand Up @@ -1700,3 +1701,35 @@
# ==========
FEATURE_FLAG_ENABLE_REFEXTRACT_SERVICE = False
REFEXTRACT_SERVICE_URL = 'http://example_refextract_url.cern.ch'

# logging
# ==========
dictConfig(
{
"version": 1,
"formatters": {
"default": {
"format": "[%(asctime)s: %(levelname)s/%(processName)s] %(name)s: %(message)s",
}
},
"handlers": {
"console": {
"level": "INFO",
"class": "logging.StreamHandler",
"formatter": "default",
"stream": sys.stdout
}
},
"loggers": {
"inspirehep.modules": {
"level": "INFO",
"handlers": ["console"],
"propagate": True
},
"": {
"level": "INFO",
"handlers": ["console"]
}
},
}
)
21 changes: 10 additions & 11 deletions inspirehep/modules/logger/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
from __future__ import absolute_import, division, print_function

import logging
import sys

# Logging config
# ==============
formatter = logging.Formatter(
"[%(asctime)s][%(levelname)s] %(name)s "
"%(filename)s:%(funcName)s:%(lineno)d | %(message)s",
)
from celery.signals import setup_logging

handler = logging.StreamHandler()
handler.setFormatter(formatter)
# Celery config
# ==============
@setup_logging.connect
def setup_basic_logging(*args, **kwargs):
logging.basicConfig(
format="%(message)s", stream=sys.stdout, level=logging.INFO
)

root_logger = logging.getLogger()
root_logger.addHandler(handler)
root_logger.setLevel(logging.INFO)

# Sentry config
# ==============
SENTRY_DSN = None
"""sentry domain"""

Expand Down

0 comments on commit 14a7fe8

Please sign in to comment.