logging_helper.aibs¶
AibsLogServerHandlerSettings ¶
Bases: ServiceSettings
Settings for the AIBS log server handler.
Attributes:
Name | Type | Description |
---|---|---|
rig_id |
str
|
The ID of the rig. |
comp_id |
str
|
The ID of the computer. |
project_name |
str
|
The name of the project. |
version |
str
|
The version of the project. |
host |
str
|
The hostname of the log server. |
port |
int
|
The port of the log server. |
level |
int
|
The logging level. |
settings_customise_sources
classmethod
¶
settings_customise_sources(
settings_cls: Type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]
Customizes the settings sources to include the safe YAML settings source.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settings_cls
|
Type[BaseSettings]
|
The settings class. |
required |
init_settings
|
PydanticBaseSettingsSource
|
The initial settings source. |
required |
env_settings
|
PydanticBaseSettingsSource
|
The environment settings source. |
required |
dotenv_settings
|
PydanticBaseSettingsSource
|
The dotenv settings source. |
required |
file_secret_settings
|
PydanticBaseSettingsSource
|
The file secret settings source. |
required |
Returns:
Type | Description |
---|---|
Tuple[PydanticBaseSettingsSource, ...]
|
A tuple of settings sources. |
Source code in src\clabe\services.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
AibsLogServerHandler ¶
AibsLogServerHandler(
settings: AibsLogServerHandlerSettings, *args, **kwargs
)
Bases: SocketHandler
A custom logging handler that sends log records to the AIBS log server.
This handler extends the standard SocketHandler to include project-specific metadata in the log records before sending them to the log server.
Attributes:
Name | Type | Description |
---|---|---|
project_name |
str
|
The name of the project. |
version |
str
|
The version of the project. |
rig_id |
str
|
The ID of the rig. |
comp_id |
str
|
The ID of the computer. |
Examples:
import logging
from clabe.logging_helper.aibs import AibsLogServerHandler, AibsLogServerHandlerSettings
# Initialize the handler with settings
settings = AibsLogServerHandlerSettings(
project_name='my_project',
version='1.0.0',
host='localhost',
port=5000
)
handler = AibsLogServerHandler(settings=settings)
# Initialize with custom level
settings = AibsLogServerHandlerSettings(
project_name='my_project',
version='1.0.0',
host='localhost',
port=5000,
level=logging.WARNING
)
handler = AibsLogServerHandler(settings=settings)
Initializes the AIBS log server handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settings
|
AibsLogServerHandlerSettings
|
AibsLogServerHandlerSettings containing all configuration options |
required |
*args
|
Additional arguments to pass to the SocketHandler. |
()
|
|
**kwargs
|
Additional keyword arguments to pass to the SocketHandler. |
{}
|
Source code in src\clabe\logging_helper\aibs.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
emit ¶
emit(record: LogRecord) -> None
Emits a log record.
Adds project-specific information to the log record before emitting it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
record
|
LogRecord
|
The log record to emit. |
required |
Source code in src\clabe\logging_helper\aibs.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
add_handler ¶
add_handler(
logger: TLogger, settings: AibsLogServerHandlerSettings
) -> TLogger
Adds an AIBS log server handler to the logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger
|
TLogger
|
The logger to add the handler to. |
required |
settings
|
AibsLogServerHandlerSettings
|
AibsLogServerHandlerSettings containing configuration options |
required |
Returns:
Type | Description |
---|---|
TLogger
|
The logger with the added handler. |
Examples:
import logging
from clabe.logging_helper.aibs import add_handler, AibsLogServerHandlerSettings
# Create a logger
logger = logging.getLogger('my_logger')
logger.setLevel(logging.INFO)
# Add the AIBS log server handler with default ERROR level
settings = AibsLogServerHandlerSettings(
project_name='my_project',
version='1.0.0',
host='localhost',
port=5000
)
logger = add_handler(logger, settings)
# Add handler with custom level
settings = AibsLogServerHandlerSettings(
project_name='my_project',
version='1.0.0',
host='localhost',
port=5000,
level=logging.WARNING
)
logger = add_handler(logger, settings)
Source code in src\clabe\logging_helper\aibs.py
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 170 171 172 173 174 175 176 177 |
|
attach_to_launcher ¶
attach_to_launcher(
launcher: TLauncher,
settings: AibsLogServerHandlerSettings,
) -> TLauncher
Attaches an AIBS log server handler to a launcher instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
launcher
|
TLauncher
|
The launcher instance to attach the handler to. |
required |
settings
|
AibsLogServerHandlerSettings
|
AibsLogServerHandlerSettings containing configuration options |
required |
Returns:
Type | Description |
---|---|
TLauncher
|
The launcher instance with the attached handler. |
Examples:
import logging
from clabe.launcher import Launcher
from clabe.logging_helper.aibs import attach_to_launcher, AibsLogServerHandlerSettings
# Initialize the launcher
launcher = MyLauncher(...) # Replace with your custom launcher class
# Attach the AIBS log server handler with default ERROR level
settings = AibsLogServerHandlerSettings(
project_name='my_launcher_project',
version='1.0.0',
host='localhost',
port=5000
)
launcher = attach_to_launcher(launcher, settings)
# Attach handler with custom level
settings = AibsLogServerHandlerSettings(
project_name='my_launcher_project',
version='1.0.0',
host='localhost',
port=5000,
level=logging.WARNING
)
launcher = attach_to_launcher(launcher, settings)
Source code in src\clabe\logging_helper\aibs.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|