🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

winston

Package Overview
Dependencies
Maintainers
4
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston - npm Package Compare versions

Comparing version

to
0.8.0

test/transports/file-open-test.js

17

lib/winston/container.js

@@ -10,3 +10,4 @@ /*

var common = require('./common'),
winston = require('../winston');
winston = require('../winston'),
extend = require('util')._extend;

@@ -40,5 +41,15 @@ //

Container.prototype.get = Container.prototype.add = function (id, options) {
var existing;
if (!this.loggers[id]) {
options = common.clone(options || this.options || this.default);
options.transports = options.transports || this.options.transports || [];
//
// Remark: Simple shallow clone for configuration options in case we pass in
// instantiated protoypal objects
//
options = extend({}, options || this.options || this.default);
existing = options.transports || this.options.transports;
//
// Remark: Make sure if we have an array of transports we slice it to make copies
// of those references.
//
options.transports = existing ? existing.slice() : [];

@@ -45,0 +56,0 @@ if (options.transports.length === 0 && (!options || !options['console'])) {

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

this.timestamp = options.timestamp != null ? options.timestamp : true;
this.logstash = options.logstash || false;

@@ -130,3 +131,4 @@ if (this.json) {

stringify: this.stringify,
label: this.label
label: this.label,
logstash: this.logstash
}) + '\n';

@@ -370,2 +372,9 @@

// If nothing to flush, there will be no "flush" event from native stream
// Thus, the "open" event will never be fired (see _createStream.createAndFlush function)
// That means, self.opening will never set to false and no logs will be written to disk
if (!this._buffer.length) {
return self.emit('flush');
}
//

@@ -440,2 +449,7 @@ // Iterate over the `_buffer` of enqueued messaged

self.once('flush', function () {
// Because "flush" event is based on native stream "drain" event,
// logs could be written inbetween "self.flush()" and here
// Therefore, we need to flush again to make sure everything is flushed
self.flush();
self.opening = false;

@@ -442,0 +456,0 @@ self.emit('open', fullname);

38

lib/winston/transports/http.js
var util = require('util'),
winston = require('../../winston'),
request = require('request'),
http = require('http'),
https = require('https'),
Stream = require('stream').Stream,

@@ -50,16 +51,21 @@ Transport = require('./transport').Transport;

options = { json: options };
options.method = 'POST';
options.url = 'http'
+ (this.ssl ? 's' : '')
+ '://'
+ (auth ? auth.username + ':' : '')
+ (auth ? auth.password + '@' : '')
+ this.host
+ ':'
+ this.port
+ '/'
+ path.replace(/^\//, '');
// Prepare options for outgoing HTTP request
req = (self.ssl ? https : http).request({
host: this.host,
port: this.port,
path: path.replace(/^\//, ''),
method: 'POST',
headers: { 'Content-Type': 'application/json' },
auth: (auth) ? auth.username + ':' + auth.password : ''
});
return request(options, callback);
req.end(new Buffer(JSON.stringify(options), 'utf8'));
req.on('error', callback);
req.on('response', function (res) {
res.on('end', function () {
callback(null, res);
});
});
};

@@ -103,4 +109,4 @@

}
this._request(options, function (err, res, body) {
this._request(options, function (err, res) {
if (res && res.statusCode !== 200) {

@@ -107,0 +113,0 @@ err = new Error('HTTP Status Code: ' + res.statusCode);

{
"name": "winston",
"description": "A multi-transport async logging library for Node.js",
"version": "0.7.3",
"version": "0.8.0",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",

@@ -24,3 +24,2 @@ "maintainers": [

"pkginfo": "0.3.x",
"request": "2.16.x",
"stack-trace": "0.0.x"

@@ -27,0 +26,0 @@ },

@@ -102,3 +102,3 @@ # winston [![Build Status](https://secure.travis-ci.org/flatiron/winston.png?branch=master)](http://travis-ci.org/flatiron/winston)

The way these objects is stored varies from transport to transport (to best support the storage mechanisms offered). Here's a quick summary of how each transports handles metadata:
The way these objects are stored varies from transport to transport (to best support the storage mechanisms offered). Here's a quick summary of how each transports handles metadata:

@@ -152,3 +152,3 @@ 1. __Console:__ Logged via util.inspect(meta)

logger.log('info', 'test message %s, %s', 'first', 'second', {number: 123}, function();
logger.log('info', 'test message %s, %s', 'first', 'second', {number: 123}, function(){});
// info: test message first, second

@@ -158,3 +158,3 @@ // meta = {numer: 123}

logger.log('info', 'test message', 'first', 'second', {number: 123}, function());
logger.log('info', 'test message', 'first', 'second', {number: 123}, function(){});
// info: test message first second

@@ -178,3 +178,3 @@ // meta = {numer: 123}

limit: 10,
start: 0
start: 0,
order: 'desc',

@@ -233,3 +233,3 @@ fields: ['message']

by default, winston will exit after logging an uncaughtException. if this is not the behavior you want,
By default, winston will exit after logging an uncaughtException. if this is not the behavior you want,
set `exitOnError = false`

@@ -327,2 +327,17 @@

You may also dynamically change the log level of a transport:
``` js
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({ level: 'warn' }),
new (winston.transports.File)({ filename: 'somefile.log', level: 'error' })
]
});
logger.debug("Will not be logged in either transport!");
logger.transports.console.level = 'debug';
logger.transports.file.level = 'verbose';
logger.verbose("Will be logged in both transports!");
```
As of 0.2.0, winston supports customizable logging levels, defaulting to [npm][0] style logging levels. Changing logging levels is easy:

@@ -619,2 +634,3 @@

* __json:__ If true, messages will be logged as JSON (default true).
* __logstash:__ If true, messages will be logged using the logstash JSON format.

@@ -621,0 +637,0 @@ *Metadata:* Logged via util.inspect(meta);

Sorry, the diff of this file is not supported yet