Skip to main content
Version: LOC v0.7 (legacy)

Logging Agent

import { LoggingAgent } from "@fstnetwork/loc-logic-sdk";

Log (debugging) messages to LOC.

The logs can be read in either Execution History panel of Studio or console output of Local Simple Runtime with CLI.

Availability

  • ✓ Generic logic
  • ✓ Aggregator logic

Error/info Logging

LoggingAgent.error(value: string | object)
ParameterDescription
valueA string message or a JSON object

If value is not valid JSON, the agent will throw an error.

note

The logging functions do not need await.

Example

export async function handleError(ctx, error) {
// log a string
LoggingAgent.info("log info");

// log a JSON object
LoggingAgent.error({
error: true,
errorMessage: error.message,
stack: error.stack,
taskId: ctx.task.taskId.id,
});
}

The outputed logs would look like this:

2022-11-08T02:21:55.219638092+00:00     Info    plaintext       log info
2022-11-08T02:21:55.221806004+00:00 Error json {"error":true,"errorMessage":"some error","stack":"Error: some error...","taskId":"..."}

Log Severity Level

Log severity level does not have impact of how you use logs, but they are useful to indicate

FunctionLevel
errorHighest
warn
info
debug
traceLowest