pino-sentry
Advanced tools
Comparing version 0.2.6 to 0.3.0
/// <reference types="node" /> | ||
import stream from 'stream'; | ||
import * as Sentry from '@sentry/node'; | ||
declare const SEVERITIES_MAP: { | ||
readonly 10: Sentry.Severity.Debug; | ||
readonly 20: Sentry.Severity.Debug; | ||
readonly 30: Sentry.Severity.Info; | ||
readonly 40: Sentry.Severity.Warning; | ||
readonly 50: Sentry.Severity.Error; | ||
readonly 60: Sentry.Severity.Fatal; | ||
readonly trace: Sentry.Severity.Debug; | ||
readonly debug: Sentry.Severity.Debug; | ||
readonly info: Sentry.Severity.Info; | ||
readonly warning: Sentry.Severity.Warning; | ||
readonly error: Sentry.Severity.Error; | ||
readonly fatal: Sentry.Severity.Fatal; | ||
}; | ||
export declare class PinoSentryTransport { | ||
private SEVERITIES_MAP; | ||
constructor(options?: Sentry.NodeOptions); | ||
getLogSeverity(level: number): Sentry.Severity; | ||
getLogSeverity(level: keyof typeof SEVERITIES_MAP): Sentry.Severity; | ||
readonly sentry: typeof Sentry; | ||
@@ -20,1 +33,2 @@ parse(line: any): void; | ||
}; | ||
export {}; |
@@ -16,33 +16,31 @@ "use strict"; | ||
} | ||
function defaults(target, source) { | ||
const ret = { ...target }; | ||
for (const key of Object.keys(source)) { | ||
if (target[key] === undefined) { | ||
ret[key] = source[key]; | ||
} | ||
} | ||
return ret; | ||
function writeToStdout() { | ||
return through2_1.default(function (chunk, _enc, cb) { | ||
this.push(chunk); | ||
process.stdout.write(chunk); | ||
cb(); | ||
}); | ||
} | ||
const SEVERITIES_MAP = { | ||
10: Sentry.Severity.Debug, | ||
20: Sentry.Severity.Debug, | ||
30: Sentry.Severity.Info, | ||
40: Sentry.Severity.Warning, | ||
50: Sentry.Severity.Error, | ||
60: Sentry.Severity.Fatal, | ||
// Support for useLevelLabels | ||
// https://github.com/pinojs/pino/blob/master/docs/api.md#uselevellabels-boolean | ||
trace: Sentry.Severity.Debug, | ||
debug: Sentry.Severity.Debug, | ||
info: Sentry.Severity.Info, | ||
warning: Sentry.Severity.Warning, | ||
error: Sentry.Severity.Error, | ||
fatal: Sentry.Severity.Fatal, | ||
}; | ||
class PinoSentryTransport { | ||
constructor(options) { | ||
this.SEVERITIES_MAP = { | ||
10: Sentry.Severity.Debug, | ||
20: Sentry.Severity.Debug, | ||
30: Sentry.Severity.Info, | ||
40: Sentry.Severity.Warning, | ||
50: Sentry.Severity.Error, | ||
60: Sentry.Severity.Fatal, | ||
// Support for useLevelLabels | ||
// https://github.com/pinojs/pino/blob/master/docs/api.md#uselevellabels-boolean | ||
trace: Sentry.Severity.Debug, | ||
debug: Sentry.Severity.Debug, | ||
info: Sentry.Severity.Info, | ||
warning: Sentry.Severity.Warning, | ||
error: Sentry.Severity.Error, | ||
fatal: Sentry.Severity.Fatal, | ||
}; | ||
Sentry.init(this.withDefaults(options || {})); | ||
} | ||
getLogSeverity(level) { | ||
return this.SEVERITIES_MAP[level] || Sentry.Severity.Info; | ||
return SEVERITIES_MAP[level] || Sentry.Severity.Info; | ||
} | ||
@@ -99,7 +97,4 @@ get sentry() { | ||
} | ||
withDefaults(options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
return defaults(options, { | ||
withDefaults(options = {}) { | ||
return { | ||
dsn: process.env.SENTRY_DSN || '', | ||
@@ -113,3 +108,4 @@ // npm_package_name will be available if ran with | ||
maxBreadcrumbs: 100, | ||
}); | ||
...options, | ||
}; | ||
} | ||
@@ -133,3 +129,3 @@ isObject(obj) { | ||
const pumpAsync = pify_1.default(pump_1.default); | ||
return pumpAsync(process.stdin, split2_1.default((line) => { | ||
return pumpAsync(process.stdin.pipe(writeToStdout()), split2_1.default((line) => { | ||
try { | ||
@@ -136,0 +132,0 @@ return JSON.parse(line); |
{ | ||
"name": "pino-sentry", | ||
"description": "@sentry/node transport for pino logger", | ||
"version": "0.2.6", | ||
"version": "0.3.0", | ||
"author": "Andrew Avdeev <andrewww.avdeev@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
25535
232
0