Skip to content

Commit

Permalink
fix: make logger to be singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Mar 7, 2020
1 parent 32310cb commit 1790794
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/debug.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const get = require("lodash.get");
const getLogger = require("./getLogger");

let opts;

const createDebugger = prefix => (...input) => {
const getLogger = require("./getLogger");
const logger = getLogger({ stdout: process.stdout, stderr: process.stderr });

// if (get(opts, prefix || "")) {
console.log(...input);
return logger.log(...input);
console.log(prefix, ...input);
return logger.log(prefix, ...input);
// }
};

Expand Down
3 changes: 2 additions & 1 deletion lib/getLogger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { Signale } = require("signale");
const once = require("lodash.once");

/**
* Return a new Signale instance.
Expand All @@ -25,4 +26,4 @@ function getLogger({ stdout, stderr }) {
}

// Exports.
module.exports = getLogger;
module.exports = once(getLogger);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"get-stream": "^5.1.0",
"git-log-parser": "^1.2.0",
"lodash.get": "^4.4.2",
"lodash.once": "^4.1.1",
"lodash.pairs": "^3.0.1",
"lodash.set": "^4.3.2",
"meow": "^6.0.1",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4775,6 +4775,11 @@ lodash.keys@^3.0.0:
lodash.isarguments "^3.0.0"
lodash.isarray "^3.0.0"

lodash.once@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac"
integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=

lodash.pairs@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash.pairs/-/lodash.pairs-3.0.1.tgz#bbe08d5786eeeaa09a15c91ebf0dcb7d2be326a9"
Expand Down

0 comments on commit 1790794

Please sign in to comment.