@cdssnc/logdriver
v0.0.2
Published
CDS Log Driver
Downloads
3
Keywords
Readme
CDS Log Driver 🇨🇦
Creates a standardized logging format for output + log collection.
standardPayload = {
cloudEventsVersion: "0.2",
contentType: "text/plain",
data: msg,
eventID: uuidv4(),
eventTime: new Date().toISOString(),
eventType: "com.github.cds-snc." + level,
eventTypeVersion: "1.0",
source: "/"
};
Adapters
StackDriver Node
import { Logger, StackDriverNodeLogger } from "@cdssnc/logger";
Logger.subscribe("error", StackDriverNodeLogger.log);
Logger.debug("The message from the server"); //logs to console + StackDriver
StackDriver Client
import { Logger, StackDriverClient } from "@cdssnc/logger";
StackDriverClient.init(
"your-api-key",
"your-project-id"
);
// window.onError should now catch and report to StackDriver
Logger.subscribe("error", StackDriverClient.log);
Logger.warn("Client side message sent to StackDriver");