Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/binary-person/rammerhead/llms.txt

Use this file to discover all available pages before exploring further.

RammerheadLogging is a lightweight leveled logger used by RammerheadProxy and all session store classes. It wraps any underlying log function and gates output by the active log level. You can swap in your own logger (winston, pino, etc.) by providing a logger function, control verbosity with logLevel, and customize the message prefix with generatePrefix.

Log levels

Levels are ordered from lowest to highest priority:
LevelDescription
'disabled'All output suppressed.
'debug'Verbose internal state and store operations.
'traffic'Every proxied HTTP and WebSocket request URL.
'info'General lifecycle events.
'warn'Recoverable issues such as corrupt session files.
'error'Unrecoverable errors.
When you set a log level, all messages at that level and above are emitted. For example, setting logLevel to 'warn' emits warn and error messages but suppresses everything else.

Constructor

const logger = new RammerheadLogging(options);
logLevel
string
default:"\"info\""
Initial log level. Must be one of 'disabled', 'debug', 'traffic', 'info', 'warn', or 'error'.
logger
(data: string) => void
default:"console.log"
The underlying log function. Must append a newline automatically (like console.log does). Called once per emitted message with the full formatted string.
loggerThis
any
default:"console"
The this context bound when calling logger. Defaults to console so that console.log works correctly when passed as logger.
generatePrefix
(level: string) => string | null
default:"defaultGeneratePrefix"
Function called before each message to produce a prefix string. The default prefix looks like [2024-01-15T12:00:00.000Z] [INFO] . Set to null to disable prefixes entirely.

Properties

logLevel

logger.logLevel         // get current level
logger.logLevel = 'debug'  // set a new level at runtime
Getter returns the current level name as a string. Setter updates the active level immediately — useful for temporarily increasing verbosity during troubleshooting.
Setting an invalid level string throws TypeError: Invalid log level '...'.

Methods

log

logger.log(level, data)
Emits data if level is at or above the current logLevel and logLevel is not 'disabled'.
level
string
required
One of the valid log level strings.
data
string
required
The message to emit. The prefix (if generatePrefix is set) is prepended automatically.

debug

logger.debug(data)
Shorthand for logger.log('debug', data).

traffic

logger.traffic(data)
Shorthand for logger.log('traffic', data). Used internally to log every proxied request URL.

info

logger.info(data)
Shorthand for logger.log('info', data).

warn

logger.warn(data)
Shorthand for logger.log('warn', data).

error

logger.error(data)
Shorthand for logger.log('error', data).

callLogger

logger.callLogger(data)
Calls the underlying logger function directly, bypassing level checks and prefix generation. Useful if you need to write a raw message regardless of the active log level.
data
string
required
Raw string passed to the underlying logger.

Examples

const { RammerheadLogging } = require('rammerhead');

const logger = new RammerheadLogging({
  logLevel: 'traffic',
  generatePrefix: (level) => `[${level.toUpperCase()}] `
});

logger.info('proxy started');
// → [INFO] proxy started

logger.traffic('GET /some-proxied-url');
// → [TRAFFIC] GET /some-proxied-url

Build docs developers (and LLMs) love