pino-sentry
Advanced tools
Comparing version 0.12.0 to 0.13.0
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import stream from 'stream'; | ||
import { AsyncResource } from 'async_hooks'; | ||
import * as Sentry from '@sentry/node'; | ||
@@ -60,3 +62,4 @@ declare type ValueOf<T> = T extends any[] ? T[number] : T[keyof T]; | ||
transformer(): stream.Transform; | ||
prepareAndGo(chunk: any, cb: any): void; | ||
prepareAndGo(chunkInfo: ChunkInfo, cb: any): void; | ||
private chunkInfoCallback; | ||
private validateOptions; | ||
@@ -67,4 +70,9 @@ private isObject; | ||
} | ||
declare class ChunkInfo extends AsyncResource { | ||
private readonly chunk; | ||
constructor(chunk: any); | ||
run<T extends readonly unknown[], R>(callback: (...args: any[]) => R, ...args: T): R; | ||
} | ||
export declare function createWriteStream(options?: PinoSentryOptions): stream.Duplex; | ||
export declare const createWriteStreamAsync: typeof createWriteStream; | ||
export {}; |
@@ -30,2 +30,3 @@ "use strict"; | ||
exports.createWriteStreamAsync = exports.createWriteStream = exports.PinoSentryTransport = exports.Severity = exports.SentryInstance = void 0; | ||
const async_hooks_1 = require("async_hooks"); | ||
const split2_1 = __importDefault(require("split2")); | ||
@@ -108,3 +109,8 @@ const pumpify_1 = __importDefault(require("pumpify")); | ||
} | ||
prepareAndGo(chunk, cb) { | ||
prepareAndGo(chunkInfo, cb) { | ||
chunkInfo.run((chunk) => { | ||
this.chunkInfoCallback(chunk, cb); | ||
}); | ||
} | ||
chunkInfoCallback(chunk, cb) { | ||
const severity = this.getLogSeverity(chunk.level); | ||
@@ -150,13 +156,9 @@ // Check if we send this Severity to Sentry | ||
const error = message instanceof Error ? message : new ExtendedError({ message, stack }); | ||
setImmediate(() => { | ||
Sentry.captureException(error, scope); | ||
cb(); | ||
}); | ||
Sentry.captureException(error, scope); | ||
setImmediate(cb); | ||
} | ||
else { | ||
// Capturing Messages | ||
setImmediate(() => { | ||
Sentry.captureMessage(message, scope); | ||
cb(); | ||
}); | ||
Sentry.captureMessage(message, scope); | ||
setImmediate(cb); | ||
} | ||
@@ -209,2 +211,16 @@ } | ||
exports.PinoSentryTransport = PinoSentryTransport; | ||
class ChunkInfo extends async_hooks_1.AsyncResource { | ||
constructor(chunk) { | ||
super("ChunkInfo"); | ||
this.chunk = chunk; | ||
} | ||
run(callback, ...args) { | ||
try { | ||
return this.runInAsyncScope(callback, undefined, this.chunk, ...args); | ||
} | ||
finally { | ||
this.emitDestroy(); | ||
} | ||
} | ||
} | ||
function createWriteStream(options) { | ||
@@ -215,3 +231,3 @@ const transport = new PinoSentryTransport(options); | ||
try { | ||
return JSON.parse(line); | ||
return new ChunkInfo(JSON.parse(line)); | ||
} | ||
@@ -218,0 +234,0 @@ catch (e) { |
@@ -60,3 +60,3 @@ { | ||
}, | ||
"version": "0.12.0" | ||
"version": "0.13.0" | ||
} |
# pino-sentry | ||
[![CircleCI](https://circleci.com/gh/aandrewww/pino-sentry.svg?style=svg)](https://circleci.com/gh/aandrewww/pino-sentry) | ||
[![node](https://img.shields.io/badge/node-10.0+-brightgreen.svg)][node-url] | ||
@@ -5,0 +4,0 @@ [![license](https://img.shields.io/github/license/aandrewww/pino-sentry.svg)][license-url] |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
40576
375
150
7