ahriman.core.log package
Submodules
ahriman.core.log.http_log_handler module
- class HttpLogHandler(repository_id: RepositoryId, configuration: Configuration, *, report: bool, suppress_errors: bool)
Bases:
Handler
handler for the http logging. Because default
logging.handlers.HTTPHandler
does not support cookies authorization, we have to implement own handler which overrides thelogging.handlers.HTTPHandler.emit()
method- suppress_errors
suppress logging errors (e.g. if no web server available)
- Type:
bool
default constructor
- Parameters:
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
suppress_errors (bool) – suppress logging errors (e.g. if no web server available)
- emit(record: LogRecord) None
emit log records using reporter client
- Parameters:
record (logging.LogRecord) – log record to log
- classmethod load(repository_id: RepositoryId, configuration: Configuration, *, report: bool) Self
install logger. This function creates handler instance and adds it to the handler list in case if no other http handler found
- Parameters:
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
report (bool) – force enable or disable reporting
- Returns:
logger instance with loaded settings
- Return type:
Self
ahriman.core.log.journal_handler module
- JournalHandler
alias of
_JournalHandler
ahriman.core.log.lazy_logging module
- class LazyLogging
Bases:
object
wrapper for the logger library inspired by scala lazy logging module
- in_package_context(package_base: str, version: str | None) Generator[None, None, None]
execute function while setting package context
- Parameters:
package_base (str) – package base to set context in
version (str | None) – package version if available
Examples
This function is designed to be called as context manager with
package_base
argument, e.g.:>>> with self.in_package_context(package.base, package.version): >>> build_package(package)
- property logger: Logger
get class logger instance
- Returns:
class logger instance
- Return type:
logging.Logger
- property logger_name: str
extract logger name for the class
- Returns:
logger name as combination of module name and class name
- Return type:
str
ahriman.core.log.log_loader module
- class LogLoader
Bases:
object
simple static method class which setups application loggers
- DEFAULT_LOG_FORMAT
(class attribute) default log format (in case of fallback)
- Type:
str
- DEFAULT_LOG_LEVEL
(class attribute) default log level (in case of fallback)
- Type:
int
- DEFAULT_SYSLOG_DEVICE
(class attribute) default path to syslog device
- Type:
Path
- static handler(selected: LogHandler | None) LogHandler
try to guess default log handler. In case if
selected
is set, it will return specified value with appended _handler suffix. Otherwise, it will try to import journald handler and returnsahriman.models.log_handler.LogHandler.Journald
if library is available. Otherwise, it will check if there is/dev/log
device and returnsahriman.models.log_handler.LogHandler.Syslog
in this case. And, finally, it will fall back toahriman.models.log_handler.LogHandler.Console
if none were found- Parameters:
selected (LogHandler | None) – user specified handler if any
- Returns:
selected log handler
- Return type:
- static load(repository_id: RepositoryId, configuration: Configuration, handler: LogHandler, *, quiet: bool, report: bool) None
setup logging settings from configuration
- Parameters:
repository_id (RepositoryId) – repository unique identifier
configuration (Configuration) – configuration instance
handler (LogHandler) – selected default log handler, which will be used if no handlers were set
quiet (bool) – force disable any log messages
report (bool) – force enable or disable reporting