kamihi.base.logging
⚓︎
Logging configuration module.
This module provides functions to configure logging for the Kamihi framework.
License
MIT
Examples:
>>> from kamihi.base.logging import configure_logging
>>> from kamihi.base.config import LogSettings
>>> from loguru import logger
>>> settings = LogSettings()
>>> configure_logging(logger, settings)
>>> logger.info("This is an info message.")
Classes:
| Name | Description |
|---|---|
MongoLogger |
MongoDB command logger. |
Functions:
| Name | Description |
|---|---|
configure_logging |
Configure logging for the module. |
MongoLogger
⚓︎
MongoLogger(logger: Logger)
Bases: CommandListener
MongoDB command logger.
This class listens to MongoDB commands and logs them using the loguru logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Logger
|
The loguru logger instance to use for logging. |
required |
Initialize the MongoLogger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Logger
|
The loguru logger instance to use for logging. |
required |
Methods:
| Name | Description |
|---|---|
failed |
Log the failure of a command. |
started |
Log the start of a command. |
succeeded |
Log the success of a command. |
Source code in src/kamihi/base/logging.py
43 44 45 46 47 48 49 50 51 52 | |
failed
⚓︎
failed(event: CommandFailedEvent) -> None
Log the failure of a command.
Source code in src/kamihi/base/logging.py
73 74 75 76 77 78 79 80 81 82 | |
started
⚓︎
started(event: CommandStartedEvent) -> None
Log the start of a command.
Source code in src/kamihi/base/logging.py
54 55 56 57 58 59 60 61 | |
succeeded
⚓︎
succeeded(event: CommandSucceededEvent) -> None
Log the success of a command.
Source code in src/kamihi/base/logging.py
63 64 65 66 67 68 69 70 71 | |
configure_logging
⚓︎
configure_logging(
logger: Logger, settings: LogSettings
) -> None
Configure logging for the module.
This function sets up the logging configuration for the module, including log level and format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Logger
|
The logger instance to configure. |
required |
|
LogSettings
|
The logging settings to configure. |
required |
Source code in src/kamihi/base/logging.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |