forked from Mirror/pmbootstrap
pmb.helpers.logging: wrap logging module (MR 2252)
We use a custom verbose log level in pmbootstrap, unfortunately it isn't possible to correctly type this due to some limitations in the logging library [1], [2]. Given that our usecase is fairly simple, we can just wrap the module with our own so we only have to tell mypy to ignore the error once instead of at every callsite. [1]: https://github.com/cryptax/droidlysis/issues/15 [2]: https://github.com/python/typing/discussions/980 Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
4b6c198ca4
commit
71e7af57e6
65 changed files with 110 additions and 69 deletions
|
@ -130,3 +130,38 @@ def init(args: PmbArgs):
|
|||
def disable():
|
||||
logger = logging.getLogger()
|
||||
logger.disabled = True
|
||||
|
||||
|
||||
# We have our own logging wrappers so we can make mypy happy
|
||||
# by not calling the (undefined) logging.verbose() function.
|
||||
|
||||
def critical(msg: object, *args, **kwargs):
|
||||
logging.critical(msg, *args, **kwargs)
|
||||
|
||||
|
||||
def fatal(msg: object, *args, **kwargs):
|
||||
logging.fatal(msg, *args, **kwargs)
|
||||
|
||||
|
||||
def error(msg: object, *args, **kwargs):
|
||||
logging.error(msg, *args, **kwargs)
|
||||
|
||||
|
||||
def warning(msg: object, *args, **kwargs):
|
||||
logging.warning(msg, *args, **kwargs)
|
||||
|
||||
|
||||
def info(msg: object, *args, **kwargs):
|
||||
logging.info(msg, *args, **kwargs)
|
||||
|
||||
|
||||
def debug(msg: object, *args, **kwargs):
|
||||
logging.debug(msg, *args, **kwargs)
|
||||
|
||||
|
||||
def verbose(msg: object, *args, **kwargs):
|
||||
logging.verbose(msg, *args, **kwargs) # type: ignore[attr-defined]
|
||||
|
||||
|
||||
def log(level: int, msg: object, *args, **kwargs):
|
||||
logging.log(level, msg, *args, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue