Skip to main content
Version: LOC v0.10 (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.

Availability

  • ✓ Generic logic
  • ✓ Aggregator logic

Error/info Logging

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

If value is an object but 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.taskKey.taskId,
});
}

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