![]() |
MantisBase v0.4.9
|
Manages SQLite database for application logs. More...
#include <log_database.h>
Public Member Functions | |
| MbLogDatabase (const MantisBase &app) | |
| Construct MbLogDatabase instance. | |
| ~MbLogDatabase () | |
| Destructor - stops cleanup thread and closes database. | |
| bool | init (const std::string &data_dir="") |
| Initialize database: create table and start cleanup thread. | |
| bool | insertLog (const std::string &level, const std::string &origin, const std::string &message, const std::string &details, const json &data=json::object()) |
| Insert a log entry into the database. | |
| json | getLogs (const std::string &after="", int limit=50, const std::string &level_filter="", const std::string &search_filter="", const std::string &start_date="", const std::string &end_date="") |
| Get logs with cursor-based pagination and filtering (ordered by id ASC). | |
Manages SQLite database for application logs.
Provides methods to store logs in a separate SQLite database, with automatic cleanup of logs older than the configured retention period.
|
explicit |
Construct MbLogDatabase instance.
| mb::MbLogDatabase::~MbLogDatabase | ( | ) |
Destructor - stops cleanup thread and closes database.
| json mb::MbLogDatabase::getLogs | ( | const std::string & | after = "", |
| int | limit = 50, | ||
| const std::string & | level_filter = "", | ||
| const std::string & | search_filter = "", | ||
| const std::string & | start_date = "", | ||
| const std::string & | end_date = "" ) |
Get logs with cursor-based pagination and filtering (ordered by id ASC).
| after | Cursor ID to fetch records after (empty = start from beginning) |
| limit | Maximum number of records to return (default 50, max 1000) |
| level_filter | Optional level filter (empty = all levels) |
| search_filter | Optional message search filter (empty = no filter) |
| start_date | Optional start date filter (ISO 8601 format, empty = no filter) |
| end_date | Optional end date filter (ISO 8601 format, empty = no filter) |
| bool mb::MbLogDatabase::init | ( | const std::string & | data_dir = "" | ) |
Initialize database: create table and start cleanup thread.
| bool mb::MbLogDatabase::insertLog | ( | const std::string & | level, |
| const std::string & | origin, | ||
| const std::string & | message, | ||
| const std::string & | details, | ||
| const json & | data = json::object() ) |
Insert a log entry into the database.
| level | Log level (trace, debug, info, warn, critical) |
| origin | Component/system origin (System, MbAuth, MbDatabase, MbEntity, MbEntitySchema, etc.) |
| message | Short message (e.g., "MbAuth Failed", "MbDatabase Connected") |
| details | Long description of the message |
| data | Optional JSON data associated with the log |