Socket
Socket
Sign inDemoInstall

winston

Package Overview
Dependencies
Maintainers
6
Versions
86
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 1.0.1 to 1.0.2

114

docs/transports.md

@@ -12,3 +12,2 @@ # Winston Transports

* [Http](#http-transport)
* [Webhook](#webhook-transport)

@@ -30,2 +29,4 @@ * **[Winston More](#winston-more)**

* [Airbrake](#airbrake-transport)
* [Newrelic](#newrelic-transport) (errors only)
* [Logsene](#logsene-transport) (including Log-Alerts and Anomaly Detection)

@@ -40,3 +41,2 @@ ## Winston Core

* [Http](#http-transport)
* [Webhook](#webhook-transport)

@@ -49,5 +49,5 @@ ### Console Transport

The Console transport takes four simple options:
The Console transport takes a few simple options:
* __level:__ Level of messages that this transport should log (default 'debug').
* __level:__ Level of messages that this transport should log (default 'info').
* __silent:__ Boolean flag indicating whether to suppress output (default false).

@@ -61,2 +61,5 @@ * __colorize:__ Boolean flag indicating if we should colorize output (default false).

* __humanReadableUnhandledException__ Boolean flag indicating if uncaught exception should be output as human readable, instead of a single line
* __showLevel:__ Boolean flag indicating if we should prepend output with level (default true).
* __formatter:__ If function is specified, its return value will be used instead of default output. (default undefined)
* __debugStdout:__ Boolean flag indicating if 'debug'-level output should be redirected to stdout instead of to stderr. (default false)

@@ -66,3 +69,2 @@ *Metadata:* Logged via util.inspect(meta);

### File Transport
``` js

@@ -72,3 +74,3 @@ winston.add(winston.transports.File, options)

The File transport should really be the 'Stream' transport since it will accept any [WritableStream][0]. It is named such because it will also accept filenames via the 'filename' option:
The File transport should really be the 'Stream' transport since it will accept any [WritableStream][14]. It is named such because it will also accept filenames via the 'filename' option:

@@ -78,5 +80,5 @@ * __level:__ Level of messages that this transport should log.

* __colorize:__ Boolean flag indicating if we should colorize output.
* __timestamp:__ Boolean flag indicating if we should prepend output with timestamps (default false). If function is specified, its return value will be used instead of timestamps.
* __timestamp:__ Boolean flag indicating if we should prepend output with timestamps (default true). If function is specified, its return value will be used instead of timestamps.
* __filename:__ The filename of the logfile to write output to.
* __maxsize:__ Max size in bytes of the logfile, if the size is exceeded then a new file is created.
* __maxsize:__ Max size in bytes of the logfile, if the size is exceeded then a new file is created, a counter will become a suffix of the log file.
* __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded.

@@ -86,7 +88,14 @@ * __stream:__ The WriteableStream to write output to.

* __eol:__ string indicating the end-of-line characters to use (default to `\n`).
* __prettyPrint:__ Boolean flag indicating if we should `util.inspect` the meta (default false). If function is specified, its return value will be the string representing the meta.
* __prettyPrint:__ If true, additional JSON metadata objects that are added to logging string messages will be displayed as a JSON string representation. If function is specified, its return value will be the string representing the meta.
* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited)
* __logstash:__ If true, messages will be logged as JSON and formatted for logstash (default false).
* __showLevel:__ Boolean flag indicating if we should prepend output with level (default true).
* __formatter:__ If function is specified and `json` is set to `false`, its return value will be used instead of default output. (default undefined)
* __tailable:__ If true, log files will be rolled based on maxsize and maxfiles, but in ascending order. The __filename__ will always have the most recent log lines. The larger the appended number, the older the log file.
* __maxRetries:__ The number of stream creation retry attempts before entering a failed state. In a failed state the transport stays active but performs a NOOP on it's log function. (default 2)
* __zippedArchive:__ If true, all log files but the current one will be zipped.
*Metadata:* Logged via util.inspect(meta);
### DailyRotateFile Transport

@@ -323,2 +332,51 @@

### Amazon DynamoDB Transport
The [winston-dynamodb][26] transport uses Amazon's DynamoDB as a sink for log messages. You can take advantage of the various authentication methods supports by Amazon's aws-sdk module. See [Configuring the SDK in Node.js](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html).
``` js
var winston = require('winston'),
winstonDynamo = require("winston-dynamodb");
winstonDynamo.DynamoDB;
winston.add(winston.transports.DynamoDB, options)
```
Options:
* __accessKeyId:__ your AWS access key id
* __secretAccessKey:__ your AWS secret access key
* __region:__ the region where the domain is hosted
* __useEnvironment:__ use process.env values for AWS access, secret, & region.
* __tableName:__ DynamoDB table name
To Configure using environment authentication:
``` js
var options = {
useEnvironment: true,
tableName: 'log'
};
winston.add(winston.transports.DynamoDB, options);
```
Also supports callbacks for completion when the DynamoDB putItem has been compelted.
### Papertrail Transport
[winston-papertrail][23] is a Papertrail transport:
``` js
var Papertrail = require('winston-papertrail').Papertrail;
winston.add(Papertrail, options);
```
The Papertrail transport connects to a [PapertrailApp log destination](https://papertrailapp.com) over TCP (TLS) using the following options:
* __level:__ Level of messages this transport should log. (default: info)
* __host:__ FQDN or IP address of the Papertrail endpoint.
* __port:__ Port for the Papertrail log destination.
* __hostname:__ The hostname associated with messages. (default: require('os').hostname())
* __program:__ The facility to send log messages.. (default: default)
* __logFormat:__ a log formatting function with the signature `function(level, message)`, which allows custom formatting of the level or message prior to delivery
*Metadata:* Logged as a native JSON object to the 'meta' attribute of the item.
### Graylog2 Transport

@@ -347,3 +405,2 @@

### Cassandra Transport

@@ -427,3 +484,38 @@

### Newrelic Transport
[newrelic-winston][23] is a Newrelic transport:
``` js
var winston = require('winston');
winston.add(require('newrelic-winston'), options);
```
The Newrelic transport will send your errors to newrelic and accepts the follwing optins:
* __env__: the current evironment. Defatuls to `process.env.NODE_ENV`
If `env` is either 'dev' or 'test' the lib will _not_ load the included newrelic module saving devs from anoying errors ;)
### Logsene Transport
[winston-logsene][24] transport for Elasticsearch bulk indexing via HTTPS to Logsene:
``` js
var winston = require('winston')
var Logsene = require('winston-logsene')
var logger = new winston.Logger()
logger.add (Logsene, {token: process.env.LOGSENE_TOKEN})
logger.info ("Info message no. %d logged to %s",1,'Logsene', {metadata: "test-log", count:1 , tags: ['test', 'info', 'winston'], memoryUsage: process.memoryUsage()})
```
Options:
* __token__: Logsene Application Token
* __source__: Source of the logs (defaults to main module)
[Logsene](http://www.sematext.com/logsene/) features:
- Fulltext search
- Anomaly detection and alerts
- Kibana4 integration
- Integration with [SPM Performance Monitoring for Node.js](http://www.sematext.com/spm/integrations/nodejs-monitoring.html)
## Find more Transports

@@ -486,1 +578,3 @@

[22]: https://github.com/rickcraig/winston-airbrake2
[23]: https://github.com/namshi/winston-newrelic
[24]: https://github.com/sematext/winston-logsene

117

lib/winston/common.js

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

fs = require('fs'),
StringDecoder = require('string_decoder').StringDecoder,
Stream = require('stream').Stream,
config = require('./config');

@@ -341,3 +343,2 @@

//

@@ -349,11 +350,10 @@ // ### function tailFile (options, callback)

//
exports.tailFile = function tail(options, callback) {
var stream = fs.createReadStream(options.file, { encoding: 'utf8' }),
buff = '',
destroy,
row = 0;
exports.tailFile = function(options, callback) {
var buffer = new Buffer(64 * 1024)
, decode = new StringDecoder('utf8')
, stream = new Stream
, buff = ''
, pos = 0
, row = 0;
destroy = stream.destroy.bind(stream);
stream.destroy = function () {};
if (options.start === -1) {

@@ -363,38 +363,87 @@ delete options.start;

stream.on('data', function (data) {
var data = (buff + data).split(/\n+/),
l = data.length - 1,
i = 0;
stream.readable = true;
stream.destroy = function() {
stream.destroyed = true;
stream.emit('end');
stream.emit('close');
};
for (; i < l; i++) {
if (options.start == null || row > options.start) {
callback(null, data[i]);
fs.open(options.file, 'a+', 0644, function(err, fd) {
if (err) {
if (!callback) {
stream.emit('error', err);
} else {
callback(err);
}
row++;
stream.destroy();
return;
}
buff = data[l];
});
(function read() {
if (stream.destroyed) {
fs.close(fd);
return;
}
stream.on('error', function (err) {
callback(err);
destroy();
});
return fs.read(fd, buffer, 0, buffer.length, pos, function(err, bytes) {
if (err) {
if (!callback) {
stream.emit('error', err);
} else {
callback(err);
}
stream.destroy();
return;
}
stream.on('end', function () {
if (buff) {
stream.emit('line', buff);
buff = '';
}
if (!bytes) {
if (buff) {
if (options.start == null || row > options.start) {
if (!callback) {
stream.emit('line', buff);
} else {
callback(null, buff);
}
}
row++;
buff = '';
}
return setTimeout(read, 1000);
}
resume();
var data = decode.write(buffer.slice(0, bytes));
if (!callback) {
stream.emit('data', data);
}
var data = (buff + data).split(/\n+/)
, l = data.length - 1
, i = 0;
for (; i < l; i++) {
if (options.start == null || row > options.start) {
if (!callback) {
stream.emit('line', data[i]);
} else {
callback(null, data[i]);
}
}
row++;
}
buff = data[l];
pos += bytes;
return read();
});
})();
});
function resume() {
setTimeout(function () {
stream.resume();
}, 1000);
if (!callback) {
return stream;
}
return destroy;
return stream.destroy;
};

@@ -397,3 +397,3 @@ /*

this._stream.once('drain', function () {
this._stream.once('finish', function () {
self.emit('flush');

@@ -400,0 +400,0 @@ self.emit('closed');

@@ -116,17 +116,21 @@ /*

Transport.prototype.logException = function (msg, meta, callback) {
var self = this;
var self = this,
called;
function onLogged () {
self.removeListener('error', onError);
callback();
if (this.silent) {
return callback();
}
function onError () {
self.removeListener('logged', onLogged);
callback();
function onComplete () {
if (!called) {
called = true;
self.removeListener('logged', onComplete);
self.removeListener('error', onComplete);
callback();
}
}
this.once('logged', onLogged);
this.once('error', onError);
this.once('logged', onComplete);
this.once('error', onComplete);
this.log(self.exceptionsLevel, msg, meta, function () { });
};
{
"name": "winston",
"description": "A multi-transport async logging library for Node.js",
"version": "1.0.1",
"version": "1.0.2",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",

@@ -19,3 +19,3 @@ "maintainers": [

"dependencies": {
"async": "0.9.x",
"async": "~1.0.0",
"colors": "1.0.x",

@@ -22,0 +22,0 @@ "cycle": "1.0.x",

# winston [![Build Status](https://secure.travis-ci.org/winstonjs/winston.svg?branch=master)](http://travis-ci.org/winstonjs/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)
A multi-transport async logging library for node.js. <span style="font-size:28px; font-weight:bold;">&quot;CHILL WINSTON! ... I put it in the logs.&quot;</span>

@@ -41,4 +43,3 @@

* [Filters and Rewriters](#filters-and-rewriters)
* [Working with transports](#working-with-transports)
* [Adding Custom Transports](#adding-custom-transports)
* [Adding Custom Transports](#adding-custom-transports)
* [Installation](#installation)

@@ -70,3 +71,3 @@ * [Run Tests](#run-tests)

For more documentation about working with each individual transport supported by Winston see the [Working with transports](#working-with-transports) section below.
For more documentation about working with each individual transport supported by Winston see the [Winston Transports](docs/transports.md) document.

@@ -195,3 +196,3 @@ ### Instantiating your own Logger

// info: test message first, second
// meta = {numer: 123}
// meta = {number: 123}
// callback = function(){}

@@ -201,3 +202,3 @@

// info: test message first second
// meta = {numer: 123}
// meta = {number: 123}
// callback = function(){}

@@ -263,7 +264,9 @@ ```

//
// Alternatively you can set `.handleExceptions` to true when adding transports to winston
// Alternatively you can set `.handleExceptions` to true when adding transports to winston.
// You can use the `.humanReadableUnhandledException` option to get more readable exceptions.
//
winston.add(winston.transports.File, {
filename: 'path/to/all-logs.log',
handleExceptions: true
handleExceptions: true,
humanReadableUnhandledException: true
});

@@ -428,3 +431,3 @@ ```

Although there is slight repetition in this data structure, it enables simple encapsulation if you not to have colors. If you do wish to have colors, in addition to passing the levels to the Logger itself, you must make winston aware of them:
Although there is slight repetition in this data structure, it enables simple encapsulation if you do not want to have colors. If you do wish to have colors, in addition to passing the levels to the Logger itself, you must make winston aware of them:

@@ -681,263 +684,6 @@ ``` js

## Working with Transports
There are many transports supported by winston core. If you have a transport you would like to add either open an issue or fork and submit a pull request. Commits are welcome, but I'll give you extra street cred if you __add tests too :D__
## Adding Custom Transports
Adding a custom transport is actually pretty easy. All you need to do is accept a couple of options, set a name, implement a log() method, and add it to the set of transports exposed by winston.
### Console Transport
``` js
winston.add(winston.transports.Console, options)
```
The Console transport takes a few simple options:
* __level:__ Level of messages that this transport should log (default 'info').
* __silent:__ Boolean flag indicating whether to suppress output (default false).
* __colorize:__ Boolean flag indicating if we should colorize output (default false).
* __timestamp:__ Boolean flag indicating if we should prepend output with timestamps (default false). If function is specified, its return value will be used instead of timestamps.
* __prettyPrint:__ Boolean flag indicating if we should `util.inspect` the meta (default false). If function is specified, its return value will be the string representing the meta.
* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited)
* __showLevel:__ Boolean flag indicating if we should prepend output with level (default true).
* __formatter:__ If function is specified, its return value will be used instead of default output. (default undefined)
* __debugStdout:__ Boolean flag indicating if 'debug'-level output should be redirected to stdout instead of to stderr. (default false)
*Metadata:* Logged via util.inspect(meta);
### File Transport
``` js
winston.add(winston.transports.File, options)
```
The File transport should really be the 'Stream' transport since it will accept any [WritableStream][14]. It is named such because it will also accept filenames via the 'filename' option:
* __level:__ Level of messages that this transport should log.
* __silent:__ Boolean flag indicating whether to suppress output.
* __colorize:__ Boolean flag indicating if we should colorize output.
* __timestamp:__ Boolean flag indicating if we should prepend output with timestamps (default true). If function is specified, its return value will be used instead of timestamps.
* __filename:__ The filename of the logfile to write output to.
* __maxsize:__ Max size in bytes of the logfile, if the size is exceeded then a new file is created, a counter will become a suffix of the log file.
* __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded.
* __stream:__ The WriteableStream to write output to.
* __json:__ If true, messages will be logged as JSON (default true).
* __prettyPrint:__ If true, additional JSON metadata objects that are added to logging string messages will be displayed as a JSON string representation. If function is specified, its return value will be the string representing the meta.
* __depth__ Numeric indicating how many times to recurse while formatting the object with `util.inspect` (only used with `prettyPrint: true`) (default null, unlimited)
* __logstash:__ If true, messages will be logged as JSON and formatted for logstash (default false).
* __showLevel:__ Boolean flag indicating if we should prepend output with level (default true).
* __formatter:__ If function is specified and `json` is set to `false`, its return value will be used instead of default output. (default undefined)
* __tailable:__ If true, log files will be rolled based on maxsize and maxfiles, but in ascending order. The __filename__ will always have the most recent log lines. The larger the appended number, the older the log file.
* __maxRetries:__ The number of stream creation retry attempts before entering a failed state. In a failed state the transport stays active but performs a NOOP on it's log function. (default 2)
* __zippedArchive:__ If true, all log files but the current one will be zipped.
*Metadata:* Logged via util.inspect(meta);
### Daily Rotate File Transport
``` js
winston.add(winston.transports.DailyRotateFile, options)
```
The Daily Rotate File transport lets you rotate log files based on time.
In addition to the options accepted by the File transport, the Daily Rotate File Transport also accepts the following option.
* __datePattern:__ Defines rolling time of a log file and suffix appended to the file. Following meta characters can be used: `yy`, `yyyy`, `M`, `MM`, `d`, `dd`, `H`, `HH`, `m`, `mm`. The default pattern is `'.yyyy-MM-dd'`. Rotation time of the log file will be equal to the smallest given time token timespan, so `'.yyyy-MM-ddTHH'` will rotate logfile every hour. You can not rotate files more frequent then every minute.
### Loggly Transport
``` js
var Loggly = require('winston-loggly').Loggly
winston.add(Loggly, options);
```
The Loggly transport is based on [Nodejitsu's][3] [node-loggly][6] implementation of the [Loggly][7] API. If you haven't heard of Loggly before, you should probably read their [value proposition][8]. The Loggly transport takes the following options. Either 'inputToken' or 'inputName' is required:
* __level:__ Level of messages that this transport should log.
* __subdomain:__ The subdomain of your Loggly account. *[required]*
* __auth__: The authentication information for your Loggly account. *[required with inputName]*
* __inputName:__ The name of the input this instance should log to.
* __inputToken:__ The input token of the input this instance should log to.
* __json:__ If true, messages will be sent to Loggly as JSON.
*Metadata:* Logged in suggested [Loggly format][2]
### Riak Transport
As of `0.3.0` the Riak transport has been broken out into a new module: [winston-riak][17]. Using it is just as easy:
``` js
var Riak = require('winston-riak').Riak;
winston.add(Riak, options);
```
In addition to the options accepted by the [riak-js][3] [client][4], the Riak transport also accepts the following options. It is worth noting that the riak-js debug option is set to *false* by default:
* __level:__ Level of messages that this transport should log.
* __bucket:__ The name of the Riak bucket you wish your logs to be in or a function to generate bucket names dynamically.
``` js
// Use a single bucket for all your logs
var singleBucketTransport = new (Riak)({ bucket: 'some-logs-go-here' });
// Generate a dynamic bucket based on the date and level
var dynamicBucketTransport = new (Riak)({
bucket: function (level, msg, meta, now) {
var d = new Date(now);
return level + [d.getDate(), d.getMonth(), d.getFullYear()].join('-');
}
});
```
*Metadata:* Logged as JSON literal in Riak
### MongoDB Transport
As of `0.3.0` the MongoDB transport has been broken out into a new module: [winston-mongodb][16]. Using it is just as easy:
``` js
var MongoDB = require('winston-mongodb').MongoDB;
winston.add(MongoDB, options);
```
For more information about its arguments, check [winston-mongodb's README][16].
* __level:__ Level of messages that this transport should log.
* __silent:__ Boolean flag indicating whether to suppress output.
* __db:__ The name of the database you want to log to. *[required]*
* __collection__: The name of the collection you want to store log messages in, defaults to 'log'.
* __safe:__ Boolean indicating if you want eventual consistency on your log messages, if set to true it requires an extra round trip to the server to ensure the write was committed, defaults to true.
* __host:__ The host running MongoDB, defaults to localhost.
* __port:__ The port on the host that MongoDB is running on, defaults to MongoDB's default port.
*Metadata:* Logged as a native JSON object.
### SimpleDB Transport
The [winston-simpledb][18] transport is just as easy:
``` js
var SimpleDB = require('winston-simpledb').SimpleDB;
winston.add(SimpleDB, options);
```
The SimpleDB transport takes the following options. All items marked with an asterisk are required:
* __awsAccessKey__:* your AWS Access Key
* __secretAccessKey__:* your AWS Secret Access Key
* __awsAccountId__:* your AWS Account Id
* __domainName__:* a string or function that returns the domain name to log to
* __region__:* the region your domain resides in
* __itemName__: a string ('uuid', 'epoch', 'timestamp') or function that returns the item name to log
*Metadata:* Logged as a native JSON object to the 'meta' attribute of the item.
### Mail Transport
The [winston-mail][19] is an email transport:
``` js
var Mail = require('winston-mail').Mail;
winston.add(Mail, options);
```
The Mail transport uses [emailjs](https://github.com/eleith/emailjs) behind the scenes. Options are the following:
* __to:__ The address(es) you want to send to. *[required]*
* __from:__ The address you want to send from. (default: `winston@[server-host-name]`)
* __host:__ SMTP server hostname (default: localhost)
* __port:__ SMTP port (default: 587 or 25)
* __username__ User for server auth
* __password__ Password for server auth
* __ssl:__ Use SSL (boolean or object { key, ca, cert })
* __tls:__ Boolean (if true, use starttls)
* __level:__ Level of messages that this transport should log.
* __silent:__ Boolean flag indicating whether to suppress output.
*Metadata:* Stringified as JSON in email.
### Amazon SNS (Simple Notification System) Transport
The [winston-sns][25] transport uses amazon SNS to send emails, texts, or a bunch of other notifications. Since this transport uses the Amazon AWS SDK for JavaScript, you can take advantage of the various methods of authentication found in Amazon's [Configuring the SDK in Node.js](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html) document.
``` js
var winston = require('winston'),
winstonSNS = require('winston-sns');
winston.add(winstonSNS, options);
```
Options:
* __subscriber:__ Subscriber number - found in your SNS AWS Console, after clicking on a topic. Same as AWS Account ID. *[required]*
* __topic_arn:__ Also found in SNS AWS Console - listed under a topic as Topic ARN. *[required]*
* __aws_key:__ Your Amazon Web Services Key.
* __aws_secret:__ Your Amazon Web Services Secret.
* __region:__ AWS Region to use. Can be one of: `us-east-1`,`us-west-1`,`eu-west-1`,`ap-southeast-1`,`ap-northeast-1`,`us-gov-west-1`,`sa-east-1`. (default: `us-east-1`)
* __subject:__ Subject for notifications. Uses placeholders for level (%l), error message (%e), and metadata (%m). (default: "Winston Error Report")
* __message:__ Message of notifications. Uses placeholders for level (%l), error message (%e), and metadata (%m). (default: "Level '%l' Error:\n%e\n\nMetadata:\n%m")
* __level:__ lowest level this transport will log. (default: `info`)
* __json:__ use json instead of a prettier (human friendly) string for meta information in the notification. (default: `false`)
* __handleExceptions:__ set to true to have this transport handle exceptions. (default: `false`)
### Graylog2 Transport
[winston-graylog2][22] is a Graylog2 transport:
``` js
var Graylog2 = require('winston-graylog2').Graylog2;
winston.add(Graylog2, options);
```
The Graylog2 transport connects to a Graylog2 server over UDP using the following options:
* __level:__ Level of messages this transport should log. (default: info)
* __silent:__ Boolean flag indicating whether to suppress output. (default: false)
* __graylogHost:__ IP address or hostname of the graylog2 server. (default: localhost)
* __graylogPort:__ Port to send messages to on the graylog2 server. (default: 12201)
* __graylogHostname:__ The hostname associated with graylog2 messages. (default: require('os').hostname())
* __graylogFacility:__ The graylog2 facility to send log messages.. (default: nodejs)
*Metadata:* Stringified as JSON in the full message GELF field.
### Papertrail Transport
[winston-papertrail][23] is a Papertrail transport:
``` js
var Papertrail = require('winston-papertrail').Papertrail;
winston.add(Papertrail, options);
```
The Papertrail transport connects to a [PapertrailApp log destination](https://papertrailapp.com) over TCP (TLS) using the following options:
* __level:__ Level of messages this transport should log. (default: info)
* __host:__ FQDN or IP address of the Papertrail endpoint.
* __port:__ Port for the Papertrail log destination.
* __hostname:__ The hostname associated with messages. (default: require('os').hostname())
* __program:__ The facility to send log messages.. (default: default)
* __logFormat:__ a log formatting function with the signature `function(level, message)`, which allows custom formatting of the level or message prior to delivery
*Metadata:* Logged as a native JSON object to the 'meta' attribute of the item.
### Cassandra Transport
[winston-cassandra][24] is a Cassandra transport:
``` js
var Cassandra = require('winston-cassandra').Cassandra;
winston.add(Cassandra, options);
```
The Cassandra transport connects to a cluster using the native protocol with the following options:
* __level:__ Level of messages that this transport should log (default: `'info'`).
* __table:__ The name of the Cassandra column family you want to store log messages in (default: `'logs'`).
* __partitionBy:__ How you want the logs to be partitioned. Possible values `'hour'` and `'day'`(Default).
* __consistency:__ The consistency of the insert query (default: `quorum`).
In addition to the options accepted by the [Node.js Cassandra driver](https://github.com/datastax/nodejs-driver) Client.
* __contactPoints:__ Cluster nodes that will handle the write requests:
Array of strings containing the contact points, for example `['host1', 'host2']` (required).
* __keyspace:__ The name of the keyspace that will contain the logs table (required). The keyspace should be already created in the cluster.
### Adding Custom Transports
Adding a custom transport (say for one of the datastore on the Roadmap) is actually pretty easy. All you need to do is accept a couple of options, set a name, implement a log() method, and add it to the set of transports exposed by winston.
``` js
var util = require('util'),

@@ -1050,1 +796,2 @@ winston = require('winston');

[25]: https://github.com/jesseditson/winston-sns
[26]: https://github.com/inspiredjw/winston-dynamodb/

Sorry, the diff of this file is not supported yet

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