discord-modmail / modmail

A Modmail bot for Discord. Allowing safe moderator conversations with server members one server at a time.
https://discord-modmail.readthedocs.io/
MIT License
15 stars 8 forks source link

logging: add config for trace loggers and logging directory #118

Closed onerandomusername closed 2 years ago

onerandomusername commented 3 years ago

Some loggers can get spammy when debugging, this allows turning them down, or setting other loggers to lower levels than the root

To use, set a MODMAIL_{level}_LOGGERS environment variable, delimiting the loggers with , Valid levels are all of the valid levels for logging, as follows trace, debug, info, notice, warning, error, critical

The directory for logging files was fully dependent on the current working directory This caused my environment to be littered with logging directories

The solution to this was to continue to use the current working directory, unless the parent directory of the bot is also a parent of the cwd, in which case the bot parent directory is used for creating the logging directory.

In addition, MODMAIL_LOGGING_DIRECTORY has been added as an override environment variable. Setting it will use that directory for logging.

codecov[bot] commented 3 years ago

Codecov Report

Merging #118 (9c40668) into main (4b07917) will decrease coverage by 0.62%. The diff coverage is 70.49%.

:exclamation: Current head 9c40668 differs from pull request most recent head 2db6223. Consider uploading reports for the commit 2db6223 to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
- Coverage   70.90%   70.28%   -0.63%     
==========================================
  Files          33       33              
  Lines        1619     1669      +50     
  Branches      199      207       +8     
==========================================
+ Hits         1148     1173      +25     
- Misses        439      461      +22     
- Partials       32       35       +3     
Impacted Files Coverage Δ
tests/modmail/test_log.py 76.47% <50.00%> (ø)
modmail/log.py 71.18% <67.30%> (-28.82%) :arrow_down:
modmail/__init__.py 100.00% <100.00%> (ø)
modmail/dispatcher.py 87.68% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a89f5d6...2db6223. Read the comment docs.

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-0.3%) to 73.031% when pulling 2db622387fcf31b81abd1a687ee33232eb4a3905 on trace-loggers into a89f5d672d48560b79d0a90b354e7f84da5d2328 on main.