@archon-inc/sdk
Version:
Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk
29 lines (28 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = recordLog;
const Archon_js_1 = require("../Archon.js");
const logging_js_1 = require("../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.
*/
async function recordLog(message, options) {
if (options.context === undefined) {
options.context = message;
}
else {
options.context = `${message}: ${options.context}`;
}
if (options.severity === undefined) {
options.severity = logging_js_1.Severity.INFO;
}
Archon_js_1.Archon.request("/logging/log", "POST", { ...options, eventType: "general", source: Archon_js_1.Archon.getComponentName() })
.catch((err) => {
console.error(`Failed to log message: ${err}`);
});
}