2022-06-26 23:30:17 +12:00
|
|
|
import logging
|
2022-10-27 14:00:48 +13:00
|
|
|
# import warnings
|
2022-06-26 23:30:17 +12:00
|
|
|
|
|
|
|
|
2022-06-26 06:51:32 +12:00
|
|
|
class LgndrException(RuntimeError):
|
|
|
|
def __init__(self, message="Error in Legendary"):
|
|
|
|
self.message = message
|
|
|
|
super(LgndrException, self).__init__(self.message)
|
2022-06-26 23:30:17 +12:00
|
|
|
|
|
|
|
|
|
|
|
class LgndrWarning(RuntimeWarning):
|
|
|
|
def __init__(self, message="Warning in Legendary"):
|
|
|
|
self.message = message
|
|
|
|
super(LgndrWarning, self).__init__(self.message)
|
|
|
|
|
|
|
|
|
2022-07-16 06:16:12 +12:00
|
|
|
class LgndrCLILogHandler(logging.Handler):
|
2022-06-26 23:30:17 +12:00
|
|
|
def emit(self, record: logging.LogRecord) -> None:
|
|
|
|
# lk: FATAL is the same as CRITICAL
|
|
|
|
if record.levelno == logging.ERROR or record.levelno == logging.CRITICAL:
|
|
|
|
raise LgndrException(record.getMessage())
|
2022-07-16 06:16:12 +12:00
|
|
|
# if record.levelno < logging.ERROR or record.levelno == logging.WARNING:
|
|
|
|
# warnings.warn(record.getMessage())
|
|
|
|
|
|
|
|
|
|
|
|
class LgndrCoreLogHandler(logging.Handler):
|
|
|
|
def emit(self, record: logging.LogRecord) -> None:
|
|
|
|
# lk: FATAL is the same as CRITICAL
|
|
|
|
if record.levelno == logging.CRITICAL:
|
|
|
|
raise LgndrException(record.getMessage())
|
|
|
|
# if record.levelno < logging.CRITICAL:
|
2022-07-10 11:34:53 +12:00
|
|
|
# warnings.warn(record.getMessage())
|