- generally saner/cleaner logger initialization In particular now it doesn't override logging level specified by the user code prior to instantiating the logger. Also remove the `LazyLogger` hack, doesn't seem like it's necessary when the above is implemented. - get rid of `logzero` which is archived and abandoned now, use `colorlog` for coloured logging formatter - allow configuring log level via shell via `LOGGING_LEVEL_module_name=<level>` E.g. `LOGGING_LEVEL_rescuexport_dal=WARNING LOGGING_LEVEL_my_rescuetime=debug ./script.py` - port `AddExceptionTraceback` from HPI/promnesia - port `CollapseLogsHandler` from HPI/promnesia Also allow configuring from the shell, e.g. `LOGGING_COLLAPSE=<level>` - add support for `enlighten` progress bar, so it can be shared between different projects See https://github.com/Rockhopper-Technologies/enlighten#readme This allows nice CLI progressbars, e.g. for parallel processing of different files from HPI: ghexport.dal[111] 29%|████████████████████████████████████████████████████████████████▏ | 29/100 [00:03<00:07, 10.03 files/s] rexport.dal[comments] 17%|████████████████████████████████████▋ | 115/682 [00:03<00:14, 39.15 files/s] my.instagram.android 0%|▎ | 3/2631 [00:02<34:50, 1.26 files/s] Currently off by default, and hidden behind an env variable (`ENLIGHTEN_ENABLE=true`)
48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
# this file only keeps the most common & critical types/utility functions
|
|
from .common import get_files, PathIsh, Paths
|
|
from .common import Json
|
|
from .common import warn_if_empty
|
|
from .common import stat, Stats
|
|
from .common import datetime_naive, datetime_aware
|
|
from .common import assert_never
|
|
|
|
from .cfg import make_config
|
|
from .error import Res, unwrap
|
|
from .logging import make_logger, LazyLogger
|
|
from .util import __NOT_HPI_MODULE__
|
|
|
|
|
|
# just for brevity in modules
|
|
# todo not sure about these.. maybe best to rely on regular imports.. perhaps compare?
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
|
|
__all__ = [
|
|
'get_files', 'PathIsh', 'Paths',
|
|
'Json',
|
|
'make_logger',
|
|
'LazyLogger', # legacy import
|
|
'warn_if_empty',
|
|
'stat', 'Stats',
|
|
'datetime_aware', 'datetime_naive',
|
|
'assert_never',
|
|
|
|
'make_config',
|
|
|
|
'__NOT_HPI_MODULE__',
|
|
|
|
'Res', 'unwrap',
|
|
|
|
'dataclass', 'Path',
|
|
]
|
|
|
|
|
|
## experimental for now
|
|
# you could put _init_hook.py next to your private my/config
|
|
# that way you can configure logging/warnings/env variables on every HPI import
|
|
try:
|
|
import my._init_hook # type: ignore[import]
|
|
except:
|
|
pass
|
|
##
|