UNPKG

pino-sentry

Version:

@sentry/node transport for pino logger

77 lines (76 loc) 2.65 kB
/// <reference types="node" /> /// <reference types="node" /> import stream from 'stream'; import { AsyncResource } from 'async_hooks'; import * as Sentry from '@sentry/node'; declare type ValueOf<T> = T extends any[] ? T[number] : T[keyof T]; export declare const SentryInstance: typeof Sentry; export declare enum Severity { Fatal = "fatal", Error = "error", Warning = "warning", Log = "log", Info = "info", Debug = "debug", Critical = "critical" } declare const SEVERITIES_MAP: { readonly 10: Severity.Debug; readonly 20: Severity.Debug; readonly 30: Severity.Info; readonly 40: Severity.Warning; readonly 50: Severity.Error; readonly 60: Severity.Fatal; readonly trace: Severity.Debug; readonly debug: Severity.Debug; readonly info: Severity.Info; readonly warning: Severity.Warning; readonly error: Severity.Error; readonly fatal: Severity.Fatal; }; declare const SeverityIota: { readonly debug: 1; readonly log: 2; readonly info: 3; readonly warning: 4; readonly error: 5; readonly fatal: 6; readonly critical: 7; }; export interface PinoSentryOptions extends Sentry.NodeOptions { /** Minimum level for a log to be reported to Sentry from pino-sentry */ level?: keyof typeof SeverityIota; messageAttributeKey?: string; extraAttributeKeys?: string[]; stackAttributeKey?: string; maxValueLength?: number; sentryExceptionLevels?: Severity[]; decorateScope?: (data: Record<string, unknown>, _scope: Sentry.Scope) => void; } export declare class PinoSentryTransport { minimumLogLevel: ValueOf<typeof SeverityIota>; messageAttributeKey: string; extraAttributeKeys: string[]; stackAttributeKey: string; maxValueLength: number; sentryExceptionLevels: Severity[]; decorateScope: (_data: Record<string, unknown>, _scope: Sentry.Scope) => void; constructor(options?: PinoSentryOptions); getLogSeverity(level: keyof typeof SEVERITIES_MAP): Severity; get sentry(): typeof Sentry; transformer(): stream.Transform; prepareAndGo(chunkInfo: ChunkInfo, cb: any): void; private chunkInfoCallback; private validateOptions; private isObject; private isSentryException; private shouldLog; } 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 {};