Skip to content

Commit be8171e

Browse files
committed
Add documentation for disabling file logging
1 parent 0b61dfe commit be8171e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ Commands:
5959
nrt Run NRT Sea Ice ECDR.
6060
```
6161

62+
### Logging
63+
64+
By default, logs are written to disk at
65+
`/share/apps/G02202_V5/{ECDR_PRODUCT_VERSION}/{YYYY-MM-DD}.log`. Up to 31 of
66+
these logs can exist at once (older log files get removed).
67+
68+
During large re-processing efforts, it may be desirable to temporarily disable
69+
logging to improve processing speed and reduce disk usage. To do so, set the
70+
`DISABLE_FILE_LOGGING` envvar to `TRUE`.
71+
72+
```
73+
export DISABLE_FILE_LOGGING=TRUE
74+
```
75+
6276
## Development/contributing
6377

6478
See [doc/development.md](doc/development.md) for more information.

seaice_ecdr/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@
2323
# regular ops runs up to a certain date, which might help w/ debugging
2424
# issues...Larger reprocessing efforts could disable file logging (or change the
2525
# level?) for speed and space consideration issues.
26-
do_not_log = os.environ.get("DISABLE_FILE_LOGGING")
26+
disable_file_logging = os.environ.get("DISABLE_FILE_LOGGING")
27+
do_not_log = disable_file_logging is not None and disable_file_logging.upper() in (
28+
"TRUE",
29+
"YES",
30+
)
31+
2732
if not do_not_log:
2833
# One file per day.
2934
file_sink_fp = LOGS_DIR / "{time:%Y-%m-%d}.log"
35+
logger.debug(f"Logging to {file_sink_fp}")
3036
logger.add(
3137
file_sink_fp,
3238
level=DEFAULT_LOG_LEVEL,
3339
# Retain logs for up to a month.
3440
retention=31,
3541
)
42+
else:
43+
logger.debug(f"Not logging to file (DISABLE_FILE_LOGGING={disable_file_logging}).")

0 commit comments

Comments
 (0)