log
Enumerations
LogLevel
Enumeration Members
Debug
Debug: 2;The “debug” level.
Designates lower priority information.
Error
Error: 5;The “error” level.
Designates very serious errors.
Info
Info: 3;The “info” level.
Designates useful information.
Trace
Trace: 1;The “trace” level.
Designates very low priority, often extremely verbose, information.
Warn
Warn: 4;The “warn” level.
Designates hazardous situations.
Interfaces
LogOptions
Properties
| Property | Type | Defined in |
|---|---|---|
file? | string | |
keyValues? | Record<string, undefined | string> | |
line? | number |
Functions
attachConsole()
function attachConsole(): Promise<UnlistenFn>Attaches a listener that writes log entries to the console as they come in.
Returns
a function to cancel the listener.
attachLogger()
function attachLogger(fn): Promise<UnlistenFn>Attaches a listener for the log, and calls the passed function for each log entry.
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | LoggerFn |
Returns
a function to cancel the listener.
debug()
function debug(message, options?): Promise<void>Logs a message at the debug level.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | # Examples import { debug } from '@crabnebula/taurify-api/log'; const pos = { x: 3.234, y: -1.223 }; debug(New position: x: {pos.x}, y: {pos.y}); |
options? | LogOptions | - |
Returns
Promise<void>
error()
function error(message, options?): Promise<void>Logs a message at the error level.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | # Examples import { error } from '@crabnebula/taurify-api/log'; const err_info = "No connection"; const port = 22; error(Error: ${err_info} on port ${port}); |
options? | LogOptions | - |
Returns
Promise<void>
info()
function info(message, options?): Promise<void>Logs a message at the info level.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | # Examples import { info } from '@crabnebula/taurify-api/log'; const conn_info = { port: 40, speed: 3.20 }; info(Connected to port {conn_info.port} at {conn_info.speed} Mb/s); |
options? | LogOptions | - |
Returns
Promise<void>
trace()
function trace(message, options?): Promise<void>Logs a message at the trace level.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | # Examples import { trace } from '@crabnebula/taurify-api/log'; let pos = { x: 3.234, y: -1.223 }; trace(Position is: x: {pos.x}, y: {pos.y}); |
options? | LogOptions | - |
Returns
Promise<void>
warn()
function warn(message, options?): Promise<void>Logs a message at the warn level.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | # Examples import { warn } from '@crabnebula/taurify-api/log'; const warn_description = "Invalid Input"; warn(Warning! {warn_description}!); |
options? | LogOptions | - |
Returns
Promise<void>