Debug Overview

Debug System Updated: Dec 10, 2025

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

LevelValueUse Case
TRACE0Very detailed debugging
DEBUG1General debugging
INFO2Important information
WARN3Warnings
ERROR4Errors
NONE5Disable 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 4

Output 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 warning

File 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
Features:
  • 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)