Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

winston-transport-sentry-node

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-transport-sentry-node - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

6

dist/transport.d.ts

@@ -5,3 +5,7 @@ import * as Sentry from '@sentry/node';

sentry?: Sentry.NodeOptions;
levelsMap?: SeverityOptions;
}
interface SeverityOptions {
[key: string]: Sentry.Severity;
}
export default class SentryTransport extends TransportStream {

@@ -14,2 +18,3 @@ silent: boolean;

readonly sentry: typeof Sentry;
private setLevelsMap;
private withDefaults;

@@ -19,1 +24,2 @@ private isObject;

}
export {};

27

dist/transport.js

@@ -6,2 +6,10 @@ "use strict";

var TransportStream = require("winston-transport");
var DEFAULT_LEVELS_MAP = {
silly: Sentry.Severity.Debug,
verbose: Sentry.Severity.Debug,
info: Sentry.Severity.Info,
debug: Sentry.Severity.Debug,
warn: Sentry.Severity.Warning,
error: Sentry.Severity.Error,
};
var ExtendedError = /** @class */ (function (_super) {

@@ -24,10 +32,15 @@ tslib_1.__extends(ExtendedError, _super);

_this.silent = false;
_this.levelsMap = {
silly: Sentry.Severity.Debug,
verbose: Sentry.Severity.Debug,
info: Sentry.Severity.Info,
debug: Sentry.Severity.Debug,
warn: Sentry.Severity.Warning,
error: Sentry.Severity.Error
_this.levelsMap = {};
_this.setLevelsMap = function (options) {
if (!options) {
return DEFAULT_LEVELS_MAP;
}
var customLevelsMap = Object.keys(options).reduce(function (acc, winstonSeverity) {
var sentrySeverity = Sentry.Severity.fromString(options[winstonSeverity]);
acc[winstonSeverity] = sentrySeverity;
return acc;
}, {});
return tslib_1.__assign(tslib_1.__assign({}, DEFAULT_LEVELS_MAP), customLevelsMap);
};
_this.levelsMap = _this.setLevelsMap(opts && opts.levelsMap);
_this.silent = opts && opts.silent || false;

@@ -34,0 +47,0 @@ Sentry.init(_this.withDefaults(opts && opts.sentry || {}));

{
"name": "winston-transport-sentry-node",
"description": "@sentry/node transport for the winston v3 logger",
"version": "0.6.0",
"version": "0.7.0",
"author": "Andrew Avdeev <andrewww.avdeev@gmail.com>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -32,3 +32,3 @@

With `new winston.Logger`:
With `winston.createLogger`:

@@ -46,3 +46,3 @@ ```js

const logger = new winston.Logger({
const logger = winston.createLogger({
transports: [

@@ -60,3 +60,3 @@ new Sentry(options)

const logger = new winston.Logger();
const logger = winston.createLogger();

@@ -76,2 +76,3 @@ logger.add(new Sentry(options));

* `format` (Object) - custom log format (see [Winston Formats](https://github.com/winstonjs/winston#formats))
* `levelsMap` (Object) - optional custom mapping between Winston's log levels and Sentry's log levels ([default](#log-level-mapping))

@@ -143,2 +144,5 @@ ### Sentry common options

See available [Sentry's levels](https://getsentry.github.io/sentry-javascript/enums/types.severity-1.html).
Matching is done with [`Sentry.Severity.fromString()`](https://getsentry.github.io/sentry-javascript/enums/types.severity-1.html#fromstring) method and will defaults to [`log`](https://getsentry.github.io/sentry-javascript/enums/types.severity-1.html#log)
## License

@@ -145,0 +149,0 @@

import * as Sentry from '@sentry/node';
import TransportStream = require("winston-transport");
const DEFAULT_LEVELS_MAP: SeverityOptions = {
silly: Sentry.Severity.Debug,
verbose: Sentry.Severity.Debug,
info: Sentry.Severity.Info,
debug: Sentry.Severity.Debug,
warn: Sentry.Severity.Warning,
error: Sentry.Severity.Error,
};
export interface SentryTransportOptions extends TransportStream.TransportStreamOptions {
sentry?: Sentry.NodeOptions;
levelsMap?: SeverityOptions;
}
interface SeverityOptions {
[key: string]: Sentry.Severity;
}
class ExtendedError extends Error {

@@ -22,10 +36,3 @@ constructor(info: any) {

private levelsMap = {
silly: Sentry.Severity.Debug,
verbose: Sentry.Severity.Debug,
info: Sentry.Severity.Info,
debug: Sentry.Severity.Debug,
warn: Sentry.Severity.Warning,
error: Sentry.Severity.Error
};
private levelsMap = {};

@@ -35,2 +42,3 @@ public constructor(opts?: SentryTransportOptions) {

this.levelsMap = this.setLevelsMap(opts && opts.levelsMap);
this.silent = opts && opts.silent || false;

@@ -97,2 +105,25 @@ Sentry.init(this.withDefaults(opts && opts.sentry || {}));

private setLevelsMap = (options?: SeverityOptions): SeverityOptions => {
if (!options) {
return DEFAULT_LEVELS_MAP;
}
const customLevelsMap = Object.keys(options).reduce(
(acc: { [key: string]: any }, winstonSeverity: string) => {
const sentrySeverity: Sentry.Severity = Sentry.Severity.fromString(
options[winstonSeverity]
);
acc[winstonSeverity] = sentrySeverity;
return acc;
},
{}
);
return {
...DEFAULT_LEVELS_MAP,
...customLevelsMap,
};
};
private withDefaults(options: Sentry.NodeOptions) {

@@ -99,0 +130,0 @@ return {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc