Debug System
Comprehensive logging with console output and file logging.
Configuration
-- Enable debug output
cLib.Debug.SetEnabled(true)
-- Set minimum log level
cLib.Debug.SetLevel("DEBUG") -- TRACE, DEBUG, INFO, WARN, ERROR
-- Set custom prefix
cLib.Debug.SetPrefix("[MyAddon]")
-- Enable file logging
cLib.Debug.SetFileLogging(true)
-- Set max history entries
cLib.Debug.SetMaxHistory(200)Log Levels
| Level | Value | Use Case |
|---|---|---|
TRACE | 0 | Very detailed debugging |
DEBUG | 1 | General debugging |
INFO | 2 | Important information |
WARN | 3 | Warnings |
ERROR | 4 | Errors |
NONE | 5 | Disable all logging |
Logging Functions
cLib.Debug.Trace("Detailed trace info") -- Level 0
cLib.Debug.Log("Debug message") -- Level 1
cLib.Debug.Info("Important info") -- Level 2
cLib.Debug.Warn("Warning!") -- Level 3
cLib.Debug.Error("Error occurred!") -- Level 4Output Format
[14:32:15] [MyAddon] [SV] [INFO] Player connected: John
[14:32:16] [MyAddon] [CL] [DEBUG] UI initialized
[14:32:20] [MyAddon] [SV] [WARN] Low memory warningFile Logging
When enabled, logs are written to:
- Server:
data/clib/logs/server_YYYY-MM-DD.log - Client:
data/clib/logs/client_YYYY-MM-DD.log
- Automatic daily rotation
- Max file size (5MB default)
- Keeps last 5 log files
-- Enable file logging
cLib.Debug.SetFileLogging(true)
-- Export current logs
local filename = cLib.Debug.ExportLogs()
print("Exported to:", filename)