Skip to content

Commit

Permalink
deps: eslint-config-logdna@2.0.0
Browse files Browse the repository at this point in the history
This enforces a 90-column width. Package dependencies
were corrected to be explicit (winston-transport)
because the linter complains about that.

Semver: patch
Ref: LOG-7378
  • Loading branch information
darinspivey committed Oct 8, 2020
1 parent 468a439 commit cabd1e5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 248 deletions.
208 changes: 0 additions & 208 deletions .eslintrc

This file was deleted.

70 changes: 35 additions & 35 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
// External Libraries
const Transport = require('winston-transport');
const Logger = require('logdna').Logger;
const stringify = require('json-stringify-safe');
'use strict'

// Constants
const DEFAULT_LEVEL = 'debug';
const DEFAULT_NAME = 'LogDNA';
const pkg = require('./package.json')
const Transport = require('winston-transport')
const Logger = require('logdna').Logger

const DEFAULT_LEVEL = 'debug'
const DEFAULT_NAME = 'LogDNA'

/*
* Support for Winston Transport
*/
module.exports = class LogDNATransport extends Transport {
constructor(options) {
const pkg = require('./package.json');
super(options);
this.name = options.name || DEFAULT_NAME;
this.level = options.level || DEFAULT_LEVEL;
this.index_meta = options.index_meta || false;
this.logger = new Logger(options.key, Object.assign({}, options, {
UserAgent: `${pkg.name}/${pkg.version}`
}));
}

log(info, callback) {
info = info || {};
constructor(options) {
super(options)
this.name = options.name || DEFAULT_NAME
this.level = options.level || DEFAULT_LEVEL
this.index_meta = options.index_meta || false
this.logger = new Logger(options.key, {
...options
, UserAgent: `${pkg.name}/${pkg.version}`
})
}

if (info.error instanceof Error) {
info.error = info.error.stack || info.error.toString();
}
log(info, callback) {
info = info || {}

if (!info.message) {
info.message = stringify(info, null, 2, function() { return undefined; });
}
if (info.error instanceof Error) {
info.error = info.error.stack || info.error.toString()
}

const { level, message, index_meta, ...meta } = info;
const opts = {
level: level
, index_meta: typeof info.index_meta === 'boolean' ? index_meta : this.index_meta
, context: meta || {}
};
if (!info.message) {
info.message = JSON.stringify(info, null, 2, function() { return undefined })
}

this.logger.log(message, opts);
if (callback) { callback(null, true); }
const {level, message, index_meta, ...meta} = info
const opts = {
level: level
, index_meta: typeof info.index_meta === 'boolean' ? index_meta : this.index_meta
, context: meta || {}
}
};

this.logger.log(message, opts)
if (callback) { callback(null, true) }
}
}
23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "LogDNA's Node.js logging module with support for Winston",
"main": "index.js",
"scripts": {
"lint": "./node_modules/.bin/eslint -c .eslintrc *.js"
"lint": "eslint ."
},
"repository": {
"type": "git",
Expand All @@ -30,11 +30,24 @@
},
"homepage": "https://github.com/logdna/logdna-winston#readme",
"dependencies": {
"logdna": "^3.5.0",
"winston": "^3.2.1"
"logdna": "^3.5.0"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^6.8.0"
"eslint": "^7.10.0",
"eslint-config-logdna": "^2.0.0",
"winston-transport": "^4.4.0"
},
"eslintConfig": {
"extends": [
"logdna"
],
"root": true,
"ignorePatterns": [
"node_modules/",
"coverage/"
],
"parserOptions": {
"ecmaVersion": 2019
}
}
}

0 comments on commit cabd1e5

Please sign in to comment.