Skip to content

Commit c42bd5e

Browse files
committed
Verbose mode targets desired logging familes
Why these changes are being introduced: Previously, when --verbose was set for the CLI all loggers inherited this. In other applications, we have used a 'WARNING_ONLY_LOGGERS' env var that would limit them to WARNING level. This worked, but was perhaps not ideal. Without that env var, it's a bit of whack-a-mole to figure out which loggers to quiet. How this addresses that need: Instead of defaulting all loggers to DEBUG in verbose mode, we target only libraries we expect this application to log in DEBUG. By default, all other logger families will still have WARNING. This may be a pattern we want to explore in other repositories. Potentially even further inverting the pattern and supporting a 'DEBUG_LOGGERS' env var list that would explicitly toggle on DEBUG logging for those libraries. That would allow troubleshooting in deployed environments just by setting an env var. This is NOT applied in this commit, but noting for future consideration. Side effects of this change: * Both 'embeddings' and 'timdex_dataset_api' are logged as DEBUG in verbose mode, but only those libraries. Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/USE-112
1 parent ce181df commit c42bd5e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

embeddings/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ def configure_logger(logger: logging.Logger, *, verbose: bool) -> str:
1010
format="%(asctime)s %(levelname)s %(name)s.%(funcName)s() line %(lineno)d: "
1111
"%(message)s"
1212
)
13-
logger.setLevel(logging.DEBUG)
13+
logging.getLogger("embeddings").setLevel(logging.DEBUG)
14+
logging.getLogger("timdex_dataset_api").setLevel(logging.DEBUG)
1415
else:
1516
logging.basicConfig(
1617
format="%(asctime)s %(levelname)s %(name)s.%(funcName)s(): %(message)s"

0 commit comments

Comments
 (0)