UNPKG

winston-cloud-logging

Version:
48 lines (47 loc) 2.03 kB
"use strict"; var _a; exports.__esModule = true; exports.format = exports.LEVEL_TO_SEVERITY = exports.CloudLoggingSeverity = exports.WinstonLevel = void 0; var winston = require("winston"); var WinstonLevel; (function (WinstonLevel) { WinstonLevel["Emergency"] = "emerg"; WinstonLevel["Alert"] = "alert"; WinstonLevel["Critical"] = "crit"; WinstonLevel["Error"] = "error"; WinstonLevel["Warning"] = "warn"; WinstonLevel["Notice"] = "notice"; WinstonLevel["Info"] = "info"; WinstonLevel["Debug"] = "debug"; })(WinstonLevel = exports.WinstonLevel || (exports.WinstonLevel = {})); var CloudLoggingSeverity; (function (CloudLoggingSeverity) { CloudLoggingSeverity["Emergency"] = "EMERGENCY"; CloudLoggingSeverity["Alert"] = "ALERT"; CloudLoggingSeverity["Critical"] = "CRITICAL"; CloudLoggingSeverity["Error"] = "ERROR"; CloudLoggingSeverity["Warning"] = "WARNING"; CloudLoggingSeverity["Notice"] = "NOTICE"; CloudLoggingSeverity["Info"] = "INFO"; CloudLoggingSeverity["Debug"] = "DEBUG"; })(CloudLoggingSeverity = exports.CloudLoggingSeverity || (exports.CloudLoggingSeverity = {})); exports.LEVEL_TO_SEVERITY = (_a = {}, _a[WinstonLevel.Emergency] = CloudLoggingSeverity.Emergency, _a[WinstonLevel.Alert] = CloudLoggingSeverity.Alert, _a[WinstonLevel.Critical] = CloudLoggingSeverity.Critical, _a[WinstonLevel.Error] = CloudLoggingSeverity.Error, _a[WinstonLevel.Warning] = CloudLoggingSeverity.Warning, _a[WinstonLevel.Notice] = CloudLoggingSeverity.Notice, _a[WinstonLevel.Info] = CloudLoggingSeverity.Info, _a[WinstonLevel.Debug] = CloudLoggingSeverity.Debug, _a); /** * Creates Cloud Logging Winston format. * The format transformation maps Winston "level" log property to the Cloud Logging compatible "severity" log property. */ exports.format = winston.format(function (info) { if (info.level in exports.LEVEL_TO_SEVERITY) { info.severity = exports.LEVEL_TO_SEVERITY[info.level]; } return info; });