my.core.logging: compatibility with HPI_LOGS

re-adds a removed check for HPI_LOGS, add some docs

fix the checks for browserexport/takeout logs to
use the computed level from my.core.logging
This commit is contained in:
Sean Breckenridge 2023-09-06 16:35:26 -07:00 committed by karlicoss
parent ff84d8fc88
commit 2a46341ce2
8 changed files with 47 additions and 20 deletions

View file

@ -81,6 +81,19 @@ def get_env_level(name: str) -> Level | None:
lvl = os.environ.get(PREFIX + name, None) or os.environ.get(PREFIX + name.replace('.', '_'), None)
if lvl is not None:
return mklevel(lvl)
# if LOGGING_LEVEL_HPI is set, use that. This should override anything the module may set as its default
# this is also set when the user passes the --debug flag in the CLI
#
# check after LOGGING_LEVEL_ prefix since that is more specific
if 'LOGGING_LEVEL_HPI' in os.environ:
return mklevel(os.environ['LOGGING_LEVEL_HPI'])
# legacy name, for backwards compatibility
if 'HPI_LOGS' in os.environ:
from my.core.warnings import medium
medium('The HPI_LOGS environment variable is deprecated, use LOGGING_LEVEL_HPI instead')
return mklevel(os.environ['HPI_LOGS'])
return None