UNPKG

@archon-inc/sdk

Version:

Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk

27 lines (24 loc) 932 B
import { Archon } from "../Archon.js"; import { LogOptions, Severity } from "../types/logging.js"; /** * **NOTE:** You should prefer other, more specific logging functions when available. Only use * this method if nothing else applies * * Log a message with options. * @param message The message to log. * @param options Options to include with the log message. */ export default async function recordLog(message: string, options: LogOptions): Promise<void> { if (options.context === undefined) { options.context = message; } else { options.context = `${message}: ${options.context}`; } if (options.severity === undefined) { options.severity = Severity.INFO; } Archon.request("/logging/log", "POST", { ...options, eventType: "general", source: Archon.getComponentName() }) .catch((err) => { console.error(`Failed to log message: ${err}`); }); }