pino-sentry
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -31,5 +31,11 @@ /// <reference types="node" /> | ||
level?: keyof typeof SeverityIota; | ||
messageAttributeKey?: string; | ||
extraAttributeKeys?: string[]; | ||
stackAttributeKey?: string; | ||
} | ||
export declare class PinoSentryTransport { | ||
minimumLogLevel: ValueOf<typeof SeverityIota>; | ||
messageAttributeKey: string; | ||
extraAttributeKeys: string[]; | ||
stackAttributeKey: string; | ||
constructor(options?: PinoSentryOptions); | ||
@@ -36,0 +42,0 @@ getLogSeverity(level: keyof typeof SEVERITIES_MAP): Sentry.Severity; |
@@ -67,2 +67,5 @@ "use strict"; | ||
this.minimumLogLevel = SeverityIota[Sentry.Severity.Debug]; | ||
this.messageAttributeKey = 'msg'; | ||
this.extraAttributeKeys = ['extra']; | ||
this.stackAttributeKey = 'stack'; | ||
Sentry.init(this.validateOptions(options || {})); | ||
@@ -99,5 +102,10 @@ } | ||
} | ||
const extra = chunk.extra || {}; | ||
const message = chunk.msg; | ||
const stack = chunk.stack || ''; | ||
const extra = {}; | ||
this.extraAttributeKeys.forEach((key) => { | ||
if (chunk[key] !== undefined) { | ||
extra[key] = chunk[key]; | ||
} | ||
}); | ||
const message = chunk[this.messageAttributeKey]; | ||
const stack = chunk[this.stackAttributeKey] || ''; | ||
Sentry.configureScope(scope => { | ||
@@ -128,2 +136,3 @@ if (this.isObject(tags)) { | ||
validateOptions(options) { | ||
var _a, _b, _c; | ||
const dsn = options.dsn || process.env.SENTRY_DSN; | ||
@@ -141,2 +150,5 @@ if (!dsn) { | ||
} | ||
this.stackAttributeKey = (_a = options.stackAttributeKey) !== null && _a !== void 0 ? _a : this.stackAttributeKey; | ||
this.extraAttributeKeys = (_b = options.extraAttributeKeys) !== null && _b !== void 0 ? _b : this.extraAttributeKeys; | ||
this.messageAttributeKey = (_c = options.messageAttributeKey) !== null && _c !== void 0 ? _c : this.messageAttributeKey; | ||
return { | ||
@@ -143,0 +155,0 @@ dsn, |
{ | ||
"name": "pino-sentry", | ||
"description": "@sentry/node transport for pino logger", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"author": "Andrew Avdeev <andrewww.avdeev@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -52,2 +52,23 @@ | ||
### Override Message Attributes | ||
In case the generated message does not follow the standard convention, the main attribute keys can be mapped to different values, when the stream gets created. Following attribute keys can be overridden: | ||
* `msg` | ||
* `extra` | ||
* `stack` | ||
```js | ||
const { createWriteStream } = require('pino-sentry'); | ||
// ... | ||
const opts = { /* ... */ }; | ||
const stream = createWriteStream({ | ||
dsn: process.env.SENTRY_DSN, | ||
messageAttributeKey: 'message', | ||
stackAttributeKey: 'trace', | ||
extraAttributeKeys: ['req', 'context'] | ||
}); | ||
const logger = pino(opts, stream); | ||
``` | ||
### Transport options | ||
@@ -54,0 +75,0 @@ |
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
32675
304
104