Skip to content

fix(logging): let debug: true reach stderr, not only the log file - #348

Open
bakiburakogun wants to merge 1 commit into
nextcloud:masterfrom
bakiburakogun:fix/debug-reaches-stderr
Open

fix(logging): let debug: true reach stderr, not only the log file#348
bakiburakogun wants to merge 1 commit into
nextcloud:masterfrom
bakiburakogun:fix/debug-reaches-stderr

Conversation

@bakiburakogun

Copy link
Copy Markdown
Contributor

Fixes #347

Problem

logger_config.yaml pins the stderr handler at WARNING, so with debug: true the detail goes to persistent_storage/logs/ccb.log while docker logs stays nearly silent. logger_config.k8s.yaml already has stderr at DEBUG, so only the manual-install and Docker paths are affected.

Everything describing what indexing is doing is INFO or DEBUGDispatching N file chunk(s), Waiting for file chunk 1/8 future to complete, embed_sources finished for 4 source(s): 3 succeeded, 1 errored with its per-source error dict. None of it surfaces. What does surface is the occasional ERROR traceback with no context around it, so from outside the container a healthy-but-slow run and a stuck one look identical.

Change

When debug is on, lower the stderr handler along with the logger levels. Reading the app config a few lines earlier is what makes it possible to decide before dictConfig runs. The default stays WARNING, so nothing changes for anyone who has not asked for debug; the file handler is untouched.

Guarded with .get() so a config without a stderr handler — a custom one, say — still starts.

Testing

On a four-node deployment with debug: true: before the change docker logs showed only startup lines and error tracebacks; after it, the batch dispatch and per-source results appear, which is what made diagnosing #345 possible without going into the container to read ccb.log.

The stderr handler is pinned at WARNING in logger_config.yaml, so with
debug: true the detail is written to persistent_storage/logs/ccb.log but
docker logs stays nearly silent. The k8s config already has stderr at DEBUG.

Everything that describes what indexing is doing is INFO or DEBUG, so from
outside the container a healthy-but-slow run and a stuck one look the same:
the only thing that surfaces is the occasional ERROR traceback, without the
context around it.

Lower the stderr handler along with the logger levels when debug is on, so
turning debug on makes the logs visible where a container deployment reads
them. Reading the app config a few lines earlier is what makes that possible.

Fixes nextcloud#347

Signed-off-by: Baki Burak Öğün <63836730+bakiburakogun@users.noreply.github.com>

@kyteinsky kyteinsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, yeah I suppose we can do this.
although the changes should be done in, they should be changed to DEBUG:


@bakiburakogun

Copy link
Copy Markdown
Contributor Author

Thanks. Before I move it I wanted to check what the change would mean, because I think it changes the behaviour rather than only relocating it.

_setup_log_levels() returns early when debug is false and does not lower anything, and in logger_config.yaml the ccb logger is already at DEBUG. So raising the stderr handler to DEBUG there would make the detail unconditional rather than tied to debug: true:

stderr handler ccb logger on stderr with debug: false
now WARNING DEBUG warnings only
with the change DEBUG DEBUG debug and warnings

logger_config.k8s.yaml arrives at the same place from the other side: the handler is already at DEBUG there, so moving the ccb logger to DEBUG has the same effect.

Which of the two would you prefer?

  • If debug output on stderr should simply be on, I will make the two config changes and drop the main.py part of this PR.
  • If it should still follow debug: true, the config changes on their own are not enough. _setup_log_levels() would also need to set the loggers to WARNING when it is false rather than returning early, and I am happy to do that here.

The main.py change goes either way. I would just rather know which of the two you want before pushing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

debug: true does not make the indexing logs visible in docker logs

2 participants