Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeemshahzad committed Oct 8, 2024
1 parent 2434881 commit 51bd007
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 49 deletions.
11 changes: 0 additions & 11 deletions notesserver/docker_gunicorn_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@

workers = 2

# Set the log level for Gunicorn
loglevel = 'info'

# Set access and error logs to std
accesslog = '-' # Access logs to stdout
errorlog = '-' # Error logs to stdout

# Define the custom access log format to match the Datadog pipeline format
access_log_format = '%(t)s %(l)s [%(r)s] [%(p)s] [dd.trace_id=%(o)s dd.span_id=%(O)s] "%(m)s %(U)s %(H)s" %(s)s %(b)s "%(f)s" "%(a)s"'


def pre_request(worker, req):
worker.log.info("%s %s" % (req.method, req.path))

Expand Down
42 changes: 4 additions & 38 deletions notesserver/settings/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def build_logging_config():
"""
Return the appropriate logging config dictionary. You should assign the
result of this to the LOGGING var in your settings.
If dev_env is set to true logging will not be done via local rsyslogd,
instead, application logs will be dropped in log_dir.
"edx_filename" is ignored unless dev_env is set to true since otherwise
logging is handled by rsyslogd.
"""
# Revert to INFO if an invalid string is passed in

Expand All @@ -37,21 +33,19 @@ def build_logging_config():
syslog_format = (
"[service_variant={service_variant}]"
"[%(name)s][env:{logging_env}] %(levelname)s "
"[{hostname} %(process)d] [%(filename)s:%(lineno)d] "
"[{hostname} %(process)d] [%(filename)s:%(lineno)d] "
"- %(message)s"
).format(service_variant=service_variant, logging_env=logging_env, hostname=hostname)

if debug:
handlers = ['console']
else:
handlers = ['local']
handlers = ['console']

logger_config = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)s %(process)d ' '[%(name)s] %(filename)s:%(lineno)d - %(message)s',
'format': '%(asctime)s,%(msecs)03d %(levelname)s [%(name)s] [%(process)d] - %(message)s',
'datefmt': '%Y-%m-%dT%H:%M:%S',
},
'syslog_format': {'format': syslog_format},
'raw': {'format': '%(message)s'},
Expand All @@ -71,32 +65,4 @@ def build_logging_config():
},
}

if dev_env:
edx_file_loc = os.path.join(log_dir, edx_filename)
logger_config['handlers'].update(
{
'local': {
'class': 'logging.handlers.RotatingFileHandler',
'level': local_loglevel,
'formatter': 'standard',
'filename': edx_file_loc,
'maxBytes': 1024 * 1024 * 2,
'backupCount': 5,
}
}
)
else:
logger_config['handlers'].update(
{
'local': {
'level': local_loglevel,
'class': 'logging.handlers.SysLogHandler',
# Use a different address for Mac OS X
'address': '/var/run/syslog' if sys.platform == "darwin" else '/dev/log',
'formatter': 'syslog_format',
'facility': SysLogHandler.LOG_LOCAL0,
}
}
)

return logger_config

0 comments on commit 51bd007

Please sign in to comment.