; #####################
; LOGGING CONFIGURATION
; #####################

[loggers]
keys = root, sqlalchemy, beaker, celery, rhodecode, ssh_wrapper

[handlers]
keys = console, console_sql

[formatters]
keys = generic, json, color_formatter, color_formatter_sql

; #######
; LOGGERS
; #######
[logger_root]
level = NOTSET
handlers = console

[logger_sqlalchemy]
level = $RC_LOGGING_LEVEL
handlers = console_sql
qualname = sqlalchemy.engine
propagate = 0

[logger_beaker]
level = $RC_LOGGING_LEVEL
handlers =
qualname = beaker.container
propagate = 1

[logger_rhodecode]
level = $RC_LOGGING_LEVEL
handlers =
qualname = rhodecode
propagate = 1

[logger_ssh_wrapper]
level = $RC_LOGGING_LEVEL
handlers =
qualname = ssh_wrapper
propagate = 1

[logger_celery]
level = $RC_LOGGING_LEVEL
handlers =
qualname = celery


; ########
; HANDLERS
; ########

[handler_console]
class = StreamHandler
args = (sys.stderr, )
level = $RC_LOGGING_LEVEL
; To enable JSON formatted logs replace 'generic' with 'json'
; This allows sending properly formatted logs to grafana loki or elasticsearch
formatter = $RC_LOGGING_FORMATTER

[handler_console_sql]
; "level = DEBUG" logs SQL queries and results.
; "level = INFO" logs SQL queries.
; "level = WARN" logs neither.  (Recommended for production systems.)
class = StreamHandler
args = (sys.stderr, )
level = WARN
; To enable JSON formatted logs replace 'generic/color_formatter_sql' with 'json'
; This allows sending properly formatted logs to grafana loki or elasticsearch
formatter = $RC_LOGGING_FORMATTER

; ##########
; FORMATTERS
; ##########

[formatter_generic]
class = rhodecode.lib.logging_formatter.ExceptionAwareFormatter
format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S

[formatter_color_formatter]
class = rhodecode.lib.logging_formatter.ColorFormatter
format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S

[formatter_color_formatter_sql]
class = rhodecode.lib.logging_formatter.ColorFormatterSql
format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y-%m-%d %H:%M:%S

[formatter_json]
format = %(timestamp)s %(levelname)s %(name)s %(message)s %(req_id)s
class = rhodecode.lib._vendor.jsonlogger.JsonFormatter
