Closed terjekv closed 11 months ago
Note that there is no review or filtering of the content returned from http requests, nor on the contents offered in POST data.
I tested the container image from the artifact in https://github.com/unioslo/mreg/actions/runs/5961486496. I got it to log something to the console after setting MREG_LOG_LEVEL=INFO
. It also created logs/app.log
, but the log file remained empty... Any ideas?
I'm willing to bet that the path to the file is broken. Fixed a bug and added some hard validation of the writability of the log file.
When testing the latest changes locally, I get no log file at all. Tried both with and without setting CI
.
I'm running docker compose up
with the following changes to docker-compose.yml
:
+ - MREG_LOG_LEVEL=INFO
+ #- CI=yes
+ volumes:
+ - /mnt/oyvind/mreg/mregsite:/app/mreg/mregsite
+ - /mnt/oyvind/mreg/logs:/app/mreg/logs
I test by first running manage.py create_mreg_superuser
inside the container, then using mreg-cli to authenticate and run host add something -f
.
Weird. Does it work if you run it with pytest or similar directly, ie, outside of a container?
Huh. It creates the logs folder, but not the file? That's really odd.
Right, this seems to be a bind issue. If I do docker exec -it /bin/sh mreg-mreg
and cat /app/logs/app.log
I see data in the log file.
Good news, it turns out I had used the wrong path for the volume. It worked after I corrected it.
At last it ensured I added some more checking and validation. :)
This change migrates the entire logging backend to structlog (https://www.structlog.org/en/stable/) and implements an internal framework to offer the following funtionality:
CI=True MREG_LOG_LEVEL=debug pytest mreg/api/v1/tests/test_hostgroups.py -vv -s
, or see https://gist.github.com/terjekv/8e97915c8b66c30241ff421a087e510dLogging to file is also supported:
An example of the output can be seen here: https://github.com/unioslo/mreg/pull/515#issuecomment-1647920124