log_write
lib callCapy
function log_write(destination : as any, event_name : as string, payload : as any = {})Description
log_write() 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.
Parameters
destination : routing, severity, and backend options
event_name : a stable name for the event
payload : event data, separate from destination options
Return Values
Nothing.
Example
Capy
log_write(backend: "file", filename: "/tmp/capy-example.log", level: "info", "agent.started", {agent_id: "agent-7"})