dandi / dandi/dandi-cli

Log directory growing to untenable sizes

Open
#1,889 1 comment 0 reactions 1 assignee Claimed by @CodyCBakerPhD View on GitHub
Dominant language
Python
Stars
28
Forks
37
Avg merge
1d 17h
Merged PRs (30d)
9

Description

I ran into a couple of logging things that seem off, wanted to check whether they're intentional before opening a PR...

On Engaging (as a part of DANDI Compute, which does a lot of automated DANDI download/upload operations) I noticed the `~/.local/state/dandi-cli/log/` directory fills up home disk space (nearly 100 GB!!)

My first instinct is to just relax the log level to error-only events instead of filling it with every last detail of run operations

But digging into it, I noticed two things:

1. `DANDI_LOG_LEVEL` doesn't seem to work from the CLI. It's honored when you use dandi as a library (it's read here in [`dandi/__init__.py`](https://github.com/dandi/dandi-cli/blob/master/dandi/__init__.py#L49)), but `main()` in `dandi/cli/command.py` calls [lgr.setLevel(logging.NOTSET)](https://github.com/dandi/dandi-cli/blob/master/dandi/cli/command.py#L90) (and [the same on the root logger](https://github.com/dandi/dandi-cli/blob/master/dandi/cli/command.py#L97)) right after, which looks like it wipes out whatever the user sets. So the env var behaves differently depending on whether you're using the CLI or the Python API

2. Every CLI run drops a new DEBUG log file that never gets cleaned up. main() [writes a fresh timestamped file to the log dir](https://github.com/dandi/dandi-cli/blob/master/dandi/cli/command.py#L102-L105) on each invocation, and the file handler is [pinned to DEBUG](https://github.com/dandi/dandi-cli/blob/master/dandi/cli/command.py#L108) no matter what `--log-level` you pass. There's no 'cache limit' nor pruning, and no way to turn it off, so it just keeps growing and growing

So is the "always log DEBUG to file regardless of --log-level" thing strictly intentional?

I would also recommend we set limits on how much this directory can grow

Any thoughts on what a sane default retention would be, like keep the last N files, or N days?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.