Socket
Socket
Sign inDemoInstall

winston

Package Overview
Dependencies
29
Maintainers
7
Versions
82
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.0 to 3.5.0

0

dist/winston.js

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /* eslint-disable no-console */

@@ -0,0 +0,0 @@ /* eslint-disable complexity,max-statements */

82

dist/winston/transports/http.js

@@ -45,2 +45,4 @@ /**

var TransportStream = require('winston-transport');
var jsonStringify = require('safe-stable-stringify');
/**

@@ -63,2 +65,3 @@ * Transport for outputting to a json-rpc server.

*/
// eslint-disable-next-line max-statements
function Http() {

@@ -82,2 +85,8 @@ var _this;

_this.headers['content-type'] = 'application/json';
_this.batch = options.batch || false;
_this.batchInterval = options.batchInterval || 5000;
_this.batchCount = options.batchCount || 10;
_this.batchOptions = [];
_this.batchTimeoutID = -1;
_this.batchCallback = {};

@@ -239,4 +248,73 @@ if (!_this.port) {

delete options.auth;
delete options.path; // Prepare options for outgoing HTTP request
delete options.path;
if (this.batch) {
this._doBatch(options, callback, auth, path);
} else {
this._doRequest(options, callback, auth, path);
}
}
/**
* Send or memorize the options according to batch configuration
* @param {function} options - Options to sent the request.
* @param {function} callback - Continuation to respond to when complete.
* @param {Object?} auth - authentication options
* @param {string} path - request path
*/
}, {
key: "_doBatch",
value: function _doBatch(options, callback, auth, path) {
this.batchOptions.push(options);
if (this.batchOptions.length === 1) {
// First message stored, it's time to start the timeout!
var me = this;
this.batchCallback = callback;
this.batchTimeoutID = setTimeout(function () {
// timeout is reached, send all messages to endpoint
me.batchTimeoutID = -1;
me._doBatchRequest(me.batchCallback, auth, path);
}, this.batchInterval);
}
if (this.batchOptions.length === this.batchCount) {
// max batch count is reached, send all messages to endpoint
this._doBatchRequest(this.batchCallback, auth, path);
}
}
/**
* Initiate a request with the memorized batch options, stop the batch timeout
* @param {function} callback - Continuation to respond to when complete.
* @param {Object?} auth - authentication options
* @param {string} path - request path
*/
}, {
key: "_doBatchRequest",
value: function _doBatchRequest(callback, auth, path) {
if (this.batchTimeoutID > 0) {
clearTimeout(this.batchTimeoutID);
this.batchTimeoutID = -1;
}
var batchOptionsCopy = this.batchOptions.slice();
this.batchOptions = [];
this._doRequest(batchOptionsCopy, callback, auth, path);
}
/**
* Make a request to a winstond server or any http server which can
* handle json-rpc.
* @param {function} options - Options to sent the request.
* @param {function} callback - Continuation to respond to when complete.
* @param {Object?} auth - authentication options
* @param {string} path - request path
*/
}, {
key: "_doRequest",
value: function _doRequest(options, callback, auth, path) {
// Prepare options for outgoing HTTP request
var headers = Object.assign({}, this.headers);

@@ -263,3 +341,3 @@

});
req.end(Buffer.from(JSON.stringify(options), 'utf8'));
req.end(Buffer.from(jsonStringify(options), 'utf8'));
}

@@ -266,0 +344,0 @@ }]);

43

index.d.ts

@@ -36,3 +36,18 @@ // Type definitions for winston 3.0

}
interface RejectionHandler {
logger: Logger;
handlers: Map<any, any>;
catcher: Function | boolean;
handle(...transports: Transport[]): void;
unhandle(...transports: Transport[]): void;
getAllInfo(err: string | Error): object;
getProcessInfo(): object;
getOsInfo(): object;
getTrace(err: Error): object;
new(logger: Logger): RejectionHandler;
}
interface QueryOptions {

@@ -54,6 +69,9 @@ rows?: number;

type LogCallback = (error?: any, level?: string, message?: string, meta?: any) => void;
type level = "error" | "warn" | "info" | "http" | "verbose" | "debug" | "silly";
type LogCallback = (error?: any, level?: level, message?: string, meta?: any) => void;
interface LogEntry {
level: string;
level: level;
message: string;

@@ -64,7 +82,7 @@ [optionName: string]: any;

interface LogMethod {
(level: string, message: string, callback: LogCallback): Logger;
(level: string, message: string, meta: any, callback: LogCallback): Logger;
(level: string, message: string, ...meta: any[]): Logger;
(level: level, message: string, callback: LogCallback): Logger;
(level: level, message: string, meta: any, callback: LogCallback): Logger;
(level: level, message: string, ...meta: any[]): Logger;
(entry: LogEntry): Logger;
(level: string, message: any): Logger;
(level: level, message: any): Logger;
}

@@ -84,3 +102,3 @@

format?: logform.Format;
level?: string;
level?: level;
exitOnError?: Function | boolean;

@@ -90,3 +108,5 @@ defaultMeta?: any;

handleExceptions?: boolean;
handleRejections?: boolean;
exceptionHandlers?: any;
rejectionHandlers?: any;
}

@@ -98,5 +118,6 @@

levels: Config.AbstractConfigSetLevels;
level: string;
level: level;
transports: Transport[];
exceptions: ExceptionHandler;
rejections: RejectionHandler;
profilers: object;

@@ -142,3 +163,3 @@ exitOnError: Function | boolean;

isLevelEnabled(level: string): boolean;
isLevelEnabled(level: level): boolean;
isErrorEnabled(): boolean;

@@ -168,2 +189,3 @@ isWarnEnabled(): boolean;

let ExceptionHandler: ExceptionHandler;
let RejectionHandler: RejectionHandler;
let Container: Container;

@@ -195,4 +217,5 @@ let loggers: Container;

let child: (options: Object) => Logger;
let level: string;
let level: level;
let exceptions: ExceptionHandler;
let rejections: RejectionHandler;
let exitOnError: Function | boolean;

@@ -199,0 +222,0 @@ // let default: object;

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /* eslint-disable no-console */

@@ -0,0 +0,0 @@ /* eslint-disable complexity,max-statements */

@@ -14,2 +14,3 @@ /**

const TransportStream = require('winston-transport');
const jsonStringify = require('safe-stable-stringify');

@@ -27,2 +28,3 @@ /**

*/
// eslint-disable-next-line max-statements
constructor(options = {}) {

@@ -41,2 +43,8 @@ super(options);

this.headers['content-type'] = 'application/json';
this.batch = options.batch || false;
this.batchInterval = options.batchInterval || 5000;
this.batchCount = options.batchCount || 10;
this.batchOptions = [];
this.batchTimeoutID = -1;
this.batchCallback = {};

@@ -183,2 +191,59 @@ if (!this.port) {

if (this.batch) {
this._doBatch(options, callback, auth, path);
} else {
this._doRequest(options, callback, auth, path);
}
}
/**
* Send or memorize the options according to batch configuration
* @param {function} options - Options to sent the request.
* @param {function} callback - Continuation to respond to when complete.
* @param {Object?} auth - authentication options
* @param {string} path - request path
*/
_doBatch(options, callback, auth, path) {
this.batchOptions.push(options);
if (this.batchOptions.length === 1) {
// First message stored, it's time to start the timeout!
const me = this;
this.batchCallback = callback;
this.batchTimeoutID = setTimeout(function () {
// timeout is reached, send all messages to endpoint
me.batchTimeoutID = -1;
me._doBatchRequest(me.batchCallback, auth, path);
}, this.batchInterval);
}
if (this.batchOptions.length === this.batchCount) {
// max batch count is reached, send all messages to endpoint
this._doBatchRequest(this.batchCallback, auth, path);
}
}
/**
* Initiate a request with the memorized batch options, stop the batch timeout
* @param {function} callback - Continuation to respond to when complete.
* @param {Object?} auth - authentication options
* @param {string} path - request path
*/
_doBatchRequest(callback, auth, path) {
if (this.batchTimeoutID > 0) {
clearTimeout(this.batchTimeoutID);
this.batchTimeoutID = -1;
}
const batchOptionsCopy = this.batchOptions.slice();
this.batchOptions = [];
this._doRequest(batchOptionsCopy, callback, auth, path);
}
/**
* Make a request to a winstond server or any http server which can
* handle json-rpc.
* @param {function} options - Options to sent the request.
* @param {function} callback - Continuation to respond to when complete.
* @param {Object?} auth - authentication options
* @param {string} path - request path
*/
_doRequest(options, callback, auth, path) {
// Prepare options for outgoing HTTP request

@@ -204,4 +269,4 @@ const headers = Object.assign({}, this.headers);

));
req.end(Buffer.from(JSON.stringify(options), 'utf8'));
req.end(Buffer.from(jsonStringify(options), 'utf8'));
}
};
{
"name": "winston",
"description": "A logger for just about everything.",
"version": "3.4.0",
"version": "3.5.0",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",

@@ -27,4 +27,4 @@ "maintainers": [

"dependencies": {
"@dabh/diagnostics": "^2.0.2",
"async": "^3.2.3",
"@dabh/diagnostics": "^2.0.2",
"is-stream": "^2.0.0",

@@ -34,2 +34,3 @@ "logform": "^2.3.2",

"readable-stream": "^3.4.0",
"safe-stable-stringify": "^2.3.1",
"stack-trace": "0.0.x",

@@ -43,3 +44,3 @@ "triple-beam": "^1.3.0",

"@babel/preset-env": "^7.16.7",
"@types/node": "^16.11.12",
"@types/node": "^17.0.8",
"abstract-winston-transport": "^0.5.1",

@@ -46,0 +47,0 @@ "assume": "^2.2.0",

@@ -8,7 +8,6 @@ # winston

[![build status](https://github.com/winstonjs/winston/actions/workflows/ci.yml/badge.svg)](https://github.com/winstonjs/winston/actions/workflows/ci.yml)
[![coverage status](https://coveralls.io/repos/github/winstonjs/winston/badge.svg?branch=master)](https://coveralls.io/github/winstonjs/winston?branch=master)
[![NPM](https://nodei.co/npm/winston.png?downloads=true&downloadRank=true)](https://nodei.co/npm/winston/)
[![Join the chat at https://gitter.im/winstonjs/winston](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/winstonjs/winston?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## winston@3

@@ -15,0 +14,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc