@archon-inc/sdk
Version:
Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk
26 lines (25 loc) • 877 B
JavaScript
import { Archon } from "../Archon.js";
import { 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, options) {
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}`);
});
}