Observability¶
Structured logging with file and TCP broadcast targets.
configure_logging¶
configure_logging(data_root=Path('./data'), log_port=None)
¶
Set up structured logging with file and TCP targets.
Parameters¶
data_root:
Root data directory. Log file is written to <data_root>/logs/kiwidb.log.
log_port:
TCP port for the log broadcast server. None reads from
LSM_LOG_PORT env var (default 9009). Pass 0 to disable TCP.
Returns¶
The :class:LogBroadcastServer instance (or None if TCP is disabled).
Source code in app/observability/logging.py
179 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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
get_logger¶
get_logger(name)
¶
Return a structlog logger bound to name.
All application modules should use::
from app.observability import get_logger
logger = get_logger(__name__)
Source code in app/observability/logging.py
LogBroadcastServer¶
LogBroadcastServer(host='127.0.0.1', port=DEFAULT_LOG_PORT)
¶
TCP server that broadcasts log lines to all connected clients.
Initialize the log broadcast server (does not start listening).
Call :meth:start to bind the socket and begin accepting clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
Network interface to bind to. |
'127.0.0.1'
|
port
|
int
|
TCP port number. Defaults to the |
DEFAULT_LOG_PORT
|
Source code in app/observability/log_server.py
port
property
¶
Return the port the server is listening on.
start()
¶
Start the broadcast server in a daemon thread.
Source code in app/observability/log_server.py
broadcast(data)
¶
Send data to all connected clients. Drop disconnected ones.
Source code in app/observability/log_server.py
stop()
¶
Shut down the server and disconnect all clients.