@pager/logger
Advanced tools
Comparing version 7.2.0 to 7.3.0
@@ -10,4 +10,5 @@ import Pino from 'pino'; | ||
export declare const errorSerializer: Pino.SerializerFn; | ||
export declare const pinoLabelToLogSeverity: (label: string) => string; | ||
export type Logger = Pino.Logger; | ||
export declare const createLogger: (options?: CreateLoggerOptions, destination?: Pino.DestinationStream) => Logger; | ||
export declare const logger: Logger; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logger = exports.createLogger = exports.errorSerializer = void 0; | ||
exports.logger = exports.createLogger = exports.pinoLabelToLogSeverity = exports.errorSerializer = void 0; | ||
const pino_1 = __importDefault(require("pino")); | ||
@@ -26,2 +26,15 @@ const pino_std_serializers_1 = require("pino-std-serializers"); | ||
exports.errorSerializer = errorSerializer; | ||
// Maps the pino label to GCP's LogSeverity enum: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity | ||
const pinoLabelToLogSeverity = (label) => { | ||
switch (label) { | ||
case 'trace': return 'DEBUG'; | ||
case 'debug': return 'DEBUG'; | ||
case 'info': return 'INFO'; | ||
case 'warn': return 'WARNING'; | ||
case 'error': return 'ERROR'; | ||
case 'fatal': return 'CRITICAL'; | ||
default: return 'DEFAULT'; | ||
} | ||
}; | ||
exports.pinoLabelToLogSeverity = pinoLabelToLogSeverity; | ||
const defaults = { | ||
@@ -76,3 +89,8 @@ /* $lab:coverage:off$ */ | ||
}, | ||
timestamp: pino_1.default.stdTimeFunctions.isoTime | ||
timestamp: pino_1.default.stdTimeFunctions.isoTime, | ||
formatters: { | ||
level: (label) => ({ | ||
severity: (0, exports.pinoLabelToLogSeverity)(label) | ||
}) | ||
} | ||
}; | ||
@@ -79,0 +97,0 @@ const handleRejections = (logger) => { |
{ | ||
"name": "@pager/logger", | ||
"version": "7.2.0", | ||
"version": "7.3.0", | ||
"description": "Logging library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16795
269