Skip to main content

Module server_logs

Module server_logs 

Source
Expand description

File to handle logging server events

This module defines functions to log different types of server events (startup, shutdown, errors) into the database. It uses a caching mechanism to minimize database queries for event type IDs, ensuring efficient logging.

StructsΒ§

EventTypeRecord πŸ”’

StaticsΒ§

ERROR_ID πŸ”’
SHUTDOWN_ID πŸ”’
STARTUP_ID πŸ”’

FunctionsΒ§

get_cached_event_type πŸ”’
Gets the cached event type ID for the given event name, using a OnceLock to cache the ID after the first retrieval.
get_or_create_event_type πŸ”’
Gets the event type ID for the given event name, creating a new event type if it doesn’t already exist.
log_error
Logs an error event to the database with the given message and error code.
log_shutdown
Logs a shutdown event to the database with the given duration in milliseconds.
log_startup
Logs a startup event to the database with the given duration in milliseconds.