log
host callCapy
function log(destination : as any, event_name : as string, payload : as any = {})
function log(value : f32) f32
function log(value : f64) f64Description
With a destination and event name, log() queues a structured operator log record. It does not write to the HTTP response, CLI output, or WebSocket connection.
Use level for severity. If backend is absent, the host uses its configured default. The built-in default is native journald with level info. The file backend appends JSON Lines to filename. The syslog backend sends records to a local socket or a remote receiver, including rsyslog.
A route selects a named destination from host configuration. Explicit destination fields override the configured defaults and route fields. Payload fields never select a destination.
The host writes records asynchronously. Logging errors do not interrupt the application. A record is dropped only when the queue already holds 1024 records or 4 MiB, or when the process ends before the writer reaches it. The host reports failures and dropped records to operators.
With one numeric argument, log(value) computes the natural logarithm. log(0.0) is negative infinity and a negative input yields NaN. Other bases divide: log(x) / log(10.0) is the decimal logarithm.
Parameters
destination : routing, severity, and backend options
event_name : a stable name for the event
payload : event data, separate from destination options
value : a positive number for the natural logarithm
Return Values
The numeric overloads return the natural logarithm in the input type. The structured logging overload returns nothing.
Example
Capy
log(backend: "file", filename: "/tmp/capy-example.log", level: "info", "agent.started", {agent_id: "agent-7"})
Output
No output
Example
Capy
print(log(1.0), " ", log(exp(2.0)), " ", log(100.0) / log(10.0), "\n")
Output
0 2 2