Log
Source:
shiva-core/server/sv_logger.lua
Structured logger with channel tagging and optional context tables. Uses FiveM colour codes for console output.
Server only
Log is a server-side global injected by shiva-core. It is not available on the client.
Availability
Log is a global in every shiva module running server-side. No import required.
Signature
All methods share the same signature:
lua
Log.<level>(channel, message, ctx?)| Param | Type | Description |
|---|---|---|
channel | string | Log channel tag, e.g. 'economy', 'boot', 'db' |
message | string | Human-readable message |
ctx | table? | Optional key-value context pairs |
Methods
Log.debug(channel, message, ctx?)
Debug message. Only emitted when shiva_debug is true.
lua
Log.debug('fishing', 'Cast line', { spot = spotId, player = source })Log.info(channel, message, ctx?)
Informational message.
lua
Log.info('economy', 'Module started')Log.warn(channel, message, ctx?)
Warning — non-fatal but worth operator attention.
lua
Log.warn('config', 'Missing key, using default', { key = 'maxItems' })Log.error(channel, message, ctx?)
Error — something failed but the server keeps running.
lua
Log.error('db', 'Query failed', { sql = sql, err = tostring(err) })Log.fatal(channel, message, ctx?)
Fatal — boot-stopping condition. Always printed regardless of debug mode.
lua
Log.fatal('boot', 'Could not connect to database')Log.success(channel, message, ctx?)
Positive milestone (green console output).
lua
Log.success('modules', 'All 73 modules loaded')Log.logError(channel, err, verbose?)
Log a structured ShivaError. Verbose mode includes the stack trace.
lua
Log.logError('economy', err)
Log.logError('economy', err, true) -- include stack traceConfiguration
| ConVar | Default | Description |
|---|---|---|
shiva_debug | false | Enable Log.debug() output |
logger.channels.console | true | Print to FiveM console |
logger.channels.discord | false | Relay to Discord webhook (Phase 2) |