feat: add colored and formatted logging
Add a custom logging setup function to add custom levels and custom formatters (partly for future use with extended logging functionality). Also implemented a basic colored formatter to make our logs nicer. Also improved the handling of logging in external libraries, so now we should only get WARNings or above. ref: N25B-233
This commit is contained in:
41
logging_config.yaml
Normal file
41
logging_config.yaml
Normal file
@@ -0,0 +1,41 @@
|
||||
version: 1
|
||||
|
||||
custom_levels:
|
||||
OBSERVATION: 25
|
||||
ACTION: 26
|
||||
|
||||
formatters:
|
||||
# Console output
|
||||
colored:
|
||||
(): 'colorlog.ColoredFormatter'
|
||||
format: '{log_color}{asctime} | {levelname:11} | {name:70} | {message}'
|
||||
style: '{'
|
||||
datefmt: '%H:%M:%S'
|
||||
|
||||
# User-facing UI (structured JSON)
|
||||
json_experiment:
|
||||
(): 'pythonjsonlogger.jsonlogger.JsonFormatter'
|
||||
format: '{asctime} {name} {levelname} {message}'
|
||||
style: '{'
|
||||
|
||||
|
||||
handlers:
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
level: DEBUG
|
||||
formatter: colored
|
||||
stream: ext://sys.stdout
|
||||
|
||||
# Level of external libraries
|
||||
root:
|
||||
level: WARN
|
||||
handlers: [console]
|
||||
|
||||
loggers:
|
||||
experiment:
|
||||
level: OBSERVATION
|
||||
handlers: [console] # TODO: custom handler for user-facing logs (ticket about UI logs)
|
||||
propagate: no
|
||||
control_backend:
|
||||
level: INFO
|
||||
|
||||
Reference in New Issue
Block a user