winston-sentry-javascript-node
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -8,3 +8,5 @@ import winston from 'winston'; | ||
new SentryTransport({ | ||
dsn: process.env.SENTRY_DSN, | ||
sentry: { | ||
dsn: process.env.SENTRY_DSN, | ||
}, | ||
level: 'error', | ||
@@ -11,0 +13,0 @@ handleExceptions: true, |
import { LogEntry } from 'winston'; | ||
import Transport, { TransportStreamOptions } from 'winston-transport'; | ||
import * as Sentry from '@sentry/node'; | ||
export interface SentryOption { | ||
dsn: string; | ||
} | ||
export interface Extra { | ||
@@ -20,5 +17,8 @@ extra?: { | ||
} | ||
export interface SentryOptions { | ||
sentry: Sentry.NodeOptions; | ||
} | ||
export declare type Log = LogEntry & Extra & Tag & UserInfo; | ||
export declare class SentryTransport extends Transport { | ||
constructor(opts: TransportStreamOptions & SentryOption); | ||
constructor(opts: TransportStreamOptions & SentryOptions); | ||
log(info: Log, next: () => void): void; | ||
@@ -25,0 +25,0 @@ private setLevel; |
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -17,6 +28,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
constructor(opts) { | ||
super(opts); | ||
Sentry.init({ | ||
dsn: opts.dsn, | ||
}); | ||
const { sentry } = opts, rest = __rest(opts, ["sentry"]); | ||
super(rest); | ||
Sentry.init(sentry); | ||
} | ||
@@ -23,0 +33,0 @@ log(info, next) { |
{ | ||
"name": "winston-sentry-javascript-node", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Sentry transport for the winson logger that using official Sentry SDK for javascript instead of the old Raven.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -29,3 +29,5 @@ <!-- | ||
new SentryTransport({ | ||
dsn: 'MY_SENTRY_DSN', | ||
sentry{ | ||
dsn: 'MY_SENTRY_DSN', | ||
}, | ||
}), | ||
@@ -66,3 +68,5 @@ ], | ||
new SentryTransport({ | ||
dsn: 'MY_SENTRY_DSN', | ||
sentry{ | ||
dsn: 'MY_SENTRY_DSN', | ||
}, | ||
handleExceptions: true, | ||
@@ -78,3 +82,5 @@ }), | ||
new SentryTransport({ | ||
dsn: 'MY_SENTRY_DSN', | ||
sentry: { | ||
dsn: 'MY_SENTRY_DSN', | ||
} | ||
}), | ||
@@ -85,2 +91,25 @@ ] | ||
## Options | ||
```javascript | ||
new SentryTransport(opts) | ||
``` | ||
* opts: TransportStreamOptions | ||
```javascript | ||
interface TransportStreamOptions { | ||
format?: logform.Format; | ||
level?: string; | ||
silent?: boolean; | ||
handleExceptions?: boolean; | ||
log?(info: any, next: () => void): any; | ||
logv?(info: any, next: () => void): any; | ||
close?(): void; | ||
} | ||
``` | ||
* opts.sentry: Please see [Sentry client options](https://docs.sentry.io/error-reporting/configuration/?platform=javascript). | ||
## Default Extra for Error Object | ||
@@ -87,0 +116,0 @@ |
@@ -5,6 +5,2 @@ import { LogEntry } from 'winston'; | ||
export interface SentryOption { | ||
dsn: string; | ||
} | ||
export interface Extra { | ||
@@ -26,10 +22,13 @@ extra?: { | ||
export interface SentryOptions { | ||
sentry: Sentry.NodeOptions; | ||
} | ||
export type Log = LogEntry & Extra & Tag & UserInfo; | ||
export class SentryTransport extends Transport { | ||
public constructor(opts: TransportStreamOptions & SentryOption) { | ||
super(opts); | ||
Sentry.init({ | ||
dsn: opts.dsn, | ||
}); | ||
public constructor(opts: TransportStreamOptions & SentryOptions) { | ||
const { sentry, ...rest } = opts; | ||
super(rest); | ||
Sentry.init(sentry); | ||
} | ||
@@ -36,0 +35,0 @@ |
Sorry, the diff of this file is not supported yet
15741
295
127