mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
adding ability to record logs for debug purposes
This commit is contained in:
32
lib/services/storage/migrations/sql/20.add-debug-logs.js
Normal file
32
lib/services/storage/migrations/sql/20.add-debug-logs.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2026 by Christian Kellner.
|
||||
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
||||
*/
|
||||
|
||||
/**
|
||||
* Migration: create the debug_logs table used by the opt-in "Debug Logging" feature.
|
||||
*
|
||||
* Each row is a single log line (timestamp + level + message) captured by the in-app
|
||||
* logger while debug logging is enabled. We store the UTF-8 byte size of the message
|
||||
* alongside the row so the debugLogStorage can maintain a rolling 5 MB cap without
|
||||
* having to run length() / SUM() on every insert.
|
||||
*
|
||||
* The "debug_logging_enabled" and "debug_logging_ever_enabled" flags are persisted in
|
||||
* the existing settings table (no schema change needed there) and are managed by
|
||||
* debugLogStorage.js at runtime.
|
||||
*/
|
||||
export function up(db) {
|
||||
// id is INTEGER PRIMARY KEY AUTOINCREMENT, which is an alias for SQLite's rowid and
|
||||
// is implicitly indexed. No additional index needed; selecting / deleting by id and
|
||||
// ordering by id ASC (rolling buffer) both use the existing rowid index.
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS debug_logs
|
||||
(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
ts INTEGER NOT NULL,
|
||||
level TEXT NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
byte_size INTEGER NOT NULL
|
||||
);
|
||||
`);
|
||||
}
|
||||
Reference in New Issue
Block a user