@rtorcato/js-common / logging
logging
Type Aliases
ConsoleLevel
ConsoleLevel =
"log"|"info"|"warn"|"error"
Defined in: logging/index.ts:61
One of the four standard console methods used by captureConsole.
Functions
logWithTimestamp()
logWithTimestamp(
message,level?):void
Defined in: logging/index.ts:13
Logs a message with a timestamp.
Example
logWithTimestamp('server started') // [2026-08-11T14:03:27.913Z] server started
logWithTimestamp('disk almost full', 'warn') // via console.warn
Parameters
message
string
The message to log.
level?
"info" | "warn" | "error"
The log level (default: 'info').
Returns
void
warn()
warn(
message):void
Defined in: logging/index.ts:29
Logs a warning message.
Example
warn('deprecated option') // [WARN] deprecated option
Parameters
message
string
The warning message.
Returns
void
error()
error(
message):void
Defined in: logging/index.ts:44
Logs an error message.
Example
error('upload failed') // [ERROR] upload failed
Parameters
message
string
The error message.
Returns
void
info()
info(
message):void
Defined in: logging/index.ts:53
Logs an info message.
Parameters
message
string
The info message.
Returns
void
captureConsole()
captureConsole(
callback): () =>void
Defined in: logging/index.ts:68
Captures all console output and returns a function to restore it.
Parameters
callback
(type, ...args) => void
Function to call with each log message.
Returns
Restore function.
() => void