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
- Error
- Warning
- Info
- Debug
- Trace
LoggingAgent.error(value: string | object)
LoggingAgent.warn(value: string | object)
LoggingAgent.info(value: string | object)
LoggingAgent.debug(value: string | object)
LoggingAgent.trace(value: string | object)
Parameter | Description |
---|---|
value | A 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
Function | Level |
---|---|
error | Highest |
warn | |
info | |
debug | |
trace | Lowest |