Skip to content

Commit

Permalink
fix(package): remove lodash as a dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicoder86 committed Nov 9, 2017
1 parent ba2ab12 commit b8b7b95
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"chalk": "2.3.0",
"cls-hooked": "4.2.2",
"event-stream": "3.3.4",
"lodash": "4.17.4",
"uuid": "3.1.0"
},
"devDependencies": {
Expand Down
18 changes: 12 additions & 6 deletions src/logger/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,34 @@

const config = require('../config');
const continuationLocalStorage = require('cls-hooked');
const _ = require('lodash');
const STACK_TRACE_LIMIT = 4000;
const Timer = require('../timer/timer');

const getContextStorage = function() {
const contextNamespace = continuationLocalStorage.getNamespace('session');

if (contextNamespace && contextNamespace.active) {
const { id, _ns_name, ...contextData } = contextNamespace.active;
return contextData;
}

return {};
};

const logMethodFactory = function(level) {
return function(action, data) {
if (!this._enabled) {
return;
}

const contextNamespace = continuationLocalStorage.getNamespace('session');
const contextStorage = (contextNamespace && contextNamespace.active) ?
_.omit(contextNamespace.active, 'id', '_ns_name') : {};

console.log(JSON.stringify(Object.assign(
{
name: this._namespace,
action: action,
level: config.levels[level].number,
time: new Date().toISOString()
},
contextStorage,
getContextStorage(),
data
)));
}
Expand Down

0 comments on commit b8b7b95

Please sign in to comment.