Conversation
| logging.getLogger('some.dependency').warning('dependency warning') | ||
|
|
||
| record = json.loads(capsys.readouterr().err.strip()) | ||
| assert record['message'] == 'dependency warning' |
There was a problem hiding this comment.
I just noticed that we don't yet have any unittest dependency. These raw asserts are not really built for tests. See for example https://docs.python.org/3/library/unittest.html
Do you see a chance to migrate our few tests?
Edit: I checked, pytest seems to be completely fine with the basic "assert". Let's keep it simple then and leave it as is.
| f'Invalid CADENZAANALYTICS_LOG_FORMAT "{log_format}". Supported values are "plain" and "ecs".' | ||
| ) | ||
|
|
||
| log_level = os.environ.get('CADENZAANALYTICS_LOG_LVL', 'INFO') |
There was a problem hiding this comment.
not sure how flexible the logging config is, but maybe an ".upper()" call might still be safer
|
Looks fine, I like having the two options and an easy switch so local development is not affected. Looks like you tried to work around some gunicorn quirks at best effort. Do the mentioned non-json lines that might be logged bother a potential json-expecting log consumer? |
Goal: Make cadenzaanalytics logging configurable to emit Elastic Common Schema (ECS) JSON, suitable for container log aggregation, covering the library itself, dependent packages, and analytics extension code — with minimal burden on extension developers.
Changes:
src/cadenzaanalytics/logging_config.pyCadenzaEcsFormatteras subclass ofecs_logging.StdlibFormatterand stamping every record with service.name/service.versiongunicorn.error/gunicorn.accessat the same handler