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

logdna-winston

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logdna-winston - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

64

index.js

@@ -1,5 +0,4 @@

var util = require('util');
var winston = require('winston');
var Logger = require('logdna').Logger;
var stringify = require('json-stringify-safe');
const Transport = require('winston-transport');
const Logger = require('logdna').Logger;
const stringify = require('json-stringify-safe');

@@ -9,42 +8,27 @@ /*

*/
var WinstonTransport = exports.WinstonTransport = function(options) {
this.name = options.name || 'LogDNA';
this.level = options.level || '';
winston.Transport.call(this, options);
this.logger = new Logger(options.key, options);
};
module.exports = class LogDNATransport extends Transport {
constructor(options) {
super(options);
this.name = options.name || 'LogDNA';
this.level = options.level || '';
this.logger = new Logger(options.key, options);
this.index_meta = options.index_meta || false;
}
util.inherits(WinstonTransport, winston.Transport);
log(level, msg, meta, callback) {
if (meta instanceof Error) { meta = { error: meta.stack || meta.toString() }; }
winston.transports.Logdna = WinstonTransport;
WinstonTransport.prototype.log = function(level, msg, meta, callback) {
if (meta instanceof Error) { meta = { error: meta.stack || meta.toString() }; }
if (!msg && !(Object.keys(meta).length === 0 && meta.constructor === Object)) {
msg = stringify(meta, null, 2, function() { return undefined; });
if (!msg && !(Object.keys(meta).length === 0 && meta.constructor === Object)) {
msg = stringify(meta, null, 2, function() { return undefined; });
}
meta = meta || {};
let opts = {
level: level
, index_meta: meta.index_meta || this.index_meta
, context: meta
};
this.logger.log(msg, opts);
if (callback) { callback(null, true); }
}
meta = meta || {};
var opts = {
level: level
, index_meta: meta.index_meta || false
, context: meta
};
this.logger.log(msg, opts);
if (callback) { callback(null, true); }
};
WinstonTransport.prototype.logException = function(msg, meta, callback) {
if (meta instanceof Error) { meta = { error: meta.stack || meta.toString() }; }
if (!msg && !(Object.keys(meta).length === 0 && meta.constructor === Object)) {
msg = stringify(meta, null, 2, function() { return undefined; });
}
meta = meta || {};
var opts = {
level: 'error'
, index_meta: meta.index_meta || false
, context: meta
};
this.logger.log(msg, opts);
};
{
"name": "logdna-winston",
"version": "1.0.0",
"version": "2.0.0",
"description": "LogDNA's Node.js logging module with support for Winston",

@@ -41,4 +41,4 @@ "main": "index.js",

"logdna": "^2.0.0",
"winston": "^2.4.0"
"winston": "^3.2.1"
}
}

@@ -21,3 +21,3 @@ <p align="center">

```javascript
$ npm install --save logdna-bunyan
$ npm install --save logdna-winston
```

@@ -34,5 +34,6 @@

```javascript
var logdna = require('logdna-winston');
var winston = require('winston');
var options = {
const logdnaWinston = require('logdna-winston');
const winston = require('winston');
const logger = winston.createLogger({});
const options = {
key: apikey,

@@ -43,12 +44,21 @@ hostname: myHostname,

app: appName,
env: envName
env: envName,
index_meta: true // Defaults to false, when true ensures meta object will be searchable
};
// Defaults to false, when true ensures meta object will be searchable
options.index_meta = true;
// Only add this line in order to track exceptions
options.handleExceptions = true;
winston.add(winston.transports.Logdna, options);
logger.add(new logdnaWinston(options));
let meta = {
data:'Some information'
};
logger.log('info', 'Log from LogDNA-winston', meta);
logger.log('debug', 'Log from LogDNA-winston', meta);
logger.log('warn', 'Log from LogDNA-winston', meta);
logger.log('error', 'Log from LogDNA-winston', meta);
logger.info('Info: Log from LogDNA-winston', meta);
logger.warn('Warn: Log from LogDNA-winston', meta);
logger.error('Error: Log from LogDNA-winston', meta);
```

@@ -55,0 +65,0 @@

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