Skip to main content
The Logger component provides a centralized logging system with multiple output targets: console, files, database, and Discord webhooks. It supports different log levels for filtering and categorizing log messages.

Log Levels

The Logger supports 6 log levels with increasing severity:

Method Signature

Important: All logger methods use this signature (not the commonly assumed signature):
Parameters:

Logging Methods

Info

Log informational message. Example:

Warn

Log warning message. Example:

Error

Log error message. Example:

Critical

Log critical failure. Example:

Trace

Log detailed debugging information. Example:

Log (Legacy)

General logging (retained for backward compatibility). Example:
Log() method is legacy. Use Info(), Warn(), Error(), etc. instead for proper log level categorization.

Output Flags

The flags parameter controls where logs are output:

Console Output

Console Format:
Log Level Filter:
  • Controlled by Convar.LOGGING.value
  • Only logs >= this level will print to console
  • Configured in server.cfg

File Output

File Structure:
File Format:
Files are organized by component name and date. New file created daily.

Discord Output

Discord logging only fires when GlobalState.IsProduction is true AND the log level meets the minimum threshold (Convar.LOGGING.value). It will not send webhooks in development mode.
Discord Webhook Configuration: Set in server.cfg:
Embed Colors:
  • trace - Gray
  • info - Blue
  • success - Green
  • warning - Yellow
  • error - Red
  • critical - Bright Red
Example:

Database Output

Database Storage:
  • Collection: logs
  • Only in production environment
  • Must pass data parameter for context
Document Structure:
Database logging only works when all of these conditions are met:
  1. Proxy.DatabaseReady is true (database connection established)
  2. GlobalState.IsProduction is true (environment set to "prod")
  3. flags.database = true is set in the flags parameter

Complete Examples

Basic Logging


Player Action Logging


Anti-Cheat Detection


Best Practices

Use the right level for the right situation:
Always pass data parameter for important logs:
Use file logging for high-frequency logs:

Next Steps

Core - Fetch

Player and character data access

Core - Database

Database operations

Configuration

Server configuration

Middleware

Event middleware system
Pro Tip: Create helper functions for common logging patterns: