Index
log_panel.handlers
¶
BufferedDatabaseHandler()
¶
Bases: DatabaseHandler
A DatabaseHandler that accumulates records in memory and flushes them in batches.
Flushes when any of the following conditions are met:
- The buffer reaches
LOG_PANEL['BUFFER_SIZE']records. - A record at or above
LOG_PANEL['BUFFER_FLUSH_LEVEL']is emitted. - A later record arrives after
LOG_PANEL['BUFFER_FLUSH_INTERVAL']seconds. flush()orclose()is called explicitly.
Batches are written with a single bulk_create call. Threshold signals fire
per-record after each flush, so alert semantics are preserved.
Records not yet flushed at process exit are lost only on abrupt termination
(SIGKILL, OOM). Normal shutdown calls close(), which drains the buffer first.
Source code in log_panel/handlers/sql.py
DatabaseHandler()
¶
Bases: Handler
Persist log records.
The target database alias is resolved via LOG_PANEL['DATABASE_ALIAS'].
Source code in log_panel/handlers/sql.py
emit(record)
¶
Format and insert a log record into the configured SQL database.
A thread-local guard prevents infinite recursion when a database execute wrapper itself emits log records while this handler is mid-write.
In ASGI contexts, Django protects the sync ORM from running inside an active event loop. Those records are persisted through a dedicated sync worker thread while preserving logging's synchronous delivery semantics.
Records emitted before the log_panel table exists (i.e. during migrate) are silently discarded so they
cannot poison an in-progress migration transaction.