Version: 1.19.0 | Updated: 2026-04-14
Nota: O recurso
static logging\u00e9 uma feature do@fluxstack/live, dispon\u00edvel mas n\u00e3o usada nos componentes de exemplo do FluxStack app.
- Per-component logging control — silent by default
- Two output channels: console (
LIVE_LOGGING) and debug panel (DEBUG_LIVE) - Both off by default — opt-in only
- 6 categories:
lifecycle,messages,state,performance,rooms,websocket console.erroralways visible regardless of config- All
liveLog/liveWarncalls are forwarded to the Live Debugger asLOGevents whenDEBUG_LIVE=true
| Channel | Env Var | Default | Purpose |
|---|---|---|---|
| Console | LIVE_LOGGING |
false |
Server terminal output |
| Debug Panel | DEBUG_LIVE |
false |
Live Debugger WebSocket stream |
The debug panel receives all liveLog/liveWarn calls as LOG events (with category, level, message, and details) regardless of the LIVE_LOGGING console setting. This keeps the console clean while making everything visible in the debug panel.
- Normal development: both off — clean console, no debug overhead
- Debugging live components:
DEBUG_LIVE=true— open the debug panel at/api/live/debug/ws - Quick console debugging:
LIVE_LOGGING=lifecycle,state— targeted categories to console - Per-component debugging:
static logging = trueon the specific component class
// app/server/live/LiveChat.ts
export class LiveChat extends LiveComponent<typeof LiveChat.defaultState> {
static componentName = 'LiveChat'
// ✅ All categories to console
static logging = true
// ✅ Specific categories only
static logging = ['lifecycle', 'rooms'] as const
// ✅ Silent (default — omit property or set false)
// No static logging needed
}Logs not tied to a specific component (connection cleanup, key rotation, etc.):
# .env
LIVE_LOGGING=true # All global logs to console
LIVE_LOGGING=lifecycle,rooms # Specific categories only
# (unset or 'false') # Silent (default)When DEBUG_LIVE=true, all liveLog/liveWarn calls emit LOG events to the Live Debugger, regardless of LIVE_LOGGING or static logging settings.
# .env
DEBUG_LIVE=true # Enable debug panel eventsEach LOG event contains:
{
type: 'LOG',
componentId: string | null,
componentName: null,
data: {
category: 'lifecycle' | 'messages' | 'state' | 'performance' | 'rooms' | 'websocket',
level: 'info' | 'warn',
message: string,
details?: unknown // Extra args passed to liveLog/liveWarn
}
}The debug panel also receives all other debug events (COMPONENT_MOUNT, STATE_CHANGE, ACTION_CALL, etc.) — see Live Components for the full event list.
| Category | What It Logs |
|---|---|
lifecycle |
Mount, unmount, rehydration, recovery, migration |
messages |
Received/sent WebSocket messages, file uploads, queue operations |
state |
Signing, backup, compression, encryption, validation |
performance |
Monitoring init, alerts, optimization suggestions |
rooms |
Room create/join/leave, emit, broadcast |
websocket |
Connection open/close/cleanup, pool management, auth |
type LiveLogCategory = 'lifecycle' | 'messages' | 'state' | 'performance' | 'rooms' | 'websocket'
type LiveLogConfig = boolean | readonly LiveLogCategory[]Use as const on arrays to get readonly tuple type:
// ✅ Works with as const
static logging = ['lifecycle', 'messages'] as constThese functions are used by the framework — app developers only need static logging or env vars:
import { liveLog, liveWarn, registerComponentLogging, unregisterComponentLogging } from '@core/server/live'
// Log gated by component config (console) + always forwarded to debug panel
liveLog('lifecycle', componentId, '🚀 Mounted component')
liveLog('rooms', componentId, `📡 Joined room '${roomId}'`)
// Warn-level (for perf alerts, non-error warnings)
liveWarn('performance', componentId, '⚠️ Slow render detected')
// Register/unregister (called on mount/unmount by ComponentRegistry)
registerComponentLogging(componentId, config)
unregisterComponentLogging(componentId)- Mount:
ComponentRegistryreadsstatic loggingfrom the class and callsregisterComponentLogging(componentId, config) - Runtime: All
liveLog()/liveWarn()calls:- Forward to the Live Debugger as
LOGevents (whenDEBUG_LIVE=true) - Check the registry before emitting to console (when
LIVE_LOGGINGorstatic loggingis active)
- Forward to the Live Debugger as
- Unmount:
unregisterComponentLogging(componentId)removes the entry - Global logs: Fall back to
LIVE_LOGGINGenv var whencomponentIdisnull
# .env
DEBUG_LIVE=true
# No LIVE_LOGGING needed — console stays cleanOpen the debug panel WebSocket at /api/live/debug/ws to see all events in real-time.
// Only this component will show console logs
export class LiveChat extends LiveComponent<typeof LiveChat.defaultState> {
static componentName = 'LiveChat'
static logging = true // See everything for this component in console
}
// All other components remain silent in console
export class LiveCounter extends LiveComponent<typeof LiveCounter.defaultState> {
static componentName = 'LiveCounter'
// No static logging → silent in console
}export class LiveChat extends LiveComponent<typeof LiveChat.defaultState> {
static componentName = 'LiveChat'
static logging = ['rooms'] as const // Only room events in console
}# .env (no LIVE_LOGGING, no DEBUG_LIVE)
# Console: silent
# Debug panel: disabled| File | Purpose |
|---|---|
core/server/live/LiveLogger.ts |
Logger implementation, registry, shouldLog logic, debugger forwarding |
core/server/live/LiveDebugger.ts |
Debug event bus, LOG event type, debug client management |
core/server/live/ComponentRegistry.ts |
Reads static logging on mount/unmount, uses liveLog |
core/server/live/websocket-plugin.ts |
Uses liveLog for WebSocket events |
core/server/live/WebSocketConnectionManager.ts |
Uses liveLog/liveWarn for connection pool management |
core/server/live/FileUploadManager.ts |
Uses liveLog/liveWarn for upload operations |
core/server/live/StateSignature.ts |
Uses liveLog/liveWarn for state operations |
core/server/live/LiveRoomManager.ts |
Uses liveLog for room lifecycle |
core/server/live/LiveComponentPerformanceMonitor.ts |
Uses liveLog/liveWarn for perf |
config/system/runtime.config.ts |
DEBUG_LIVE env var config |
core/types/types.ts |
LiveComponent base class with static logging property |
ALWAYS:
- Use
as conston logging arrays for type safety - Keep components silent by default (no
static logging) - Use
DEBUG_LIVE=truefor debugging instead ofstatic loggingon components - Use specific categories instead of
truewhen possible
NEVER:
- Use
console.logdirectly in Live Component code — useliveLog() - Forget that
console.erroris always visible (not gated) - Enable
LIVE_LOGGINGorDEBUG_LIVEin production
- Live Components - Base component system
- Live Rooms - Room system (logged under
roomscategory) - Environment Variables -
LIVE_LOGGINGandDEBUG_LIVEreference