-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added debug mode emitting underlying configuration #122
base: main
Are you sure you want to change the base?
Conversation
// TODO: move into faucet-core | ||
exports.DEBUG = process.env.FAUCET_ENV === "DEBUG"; | ||
exports.debug = exports.DEBUG === false ? noop : (...msg) => { | ||
msg = msg.map(arg => (arg && !arg.substr) ? JSON.stringify(arg, null, 4) : arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON.stringify
avoids [Object]
being emitted for nested objects
it also happens to filter out plugin functions, which might be good or bad
@@ -2,6 +2,13 @@ | |||
|
|||
let NOTIFY = '(typeof alert !== "undefined" ? alert : console.error)'; | |||
|
|||
// TODO: move into faucet-core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
@@ -2,6 +2,13 @@ | |||
|
|||
let NOTIFY = '(typeof alert !== "undefined" ? alert : console.error)'; | |||
|
|||
// TODO: move into faucet-core | |||
exports.DEBUG = process.env.FAUCET_ENV === "DEBUG"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows avoiding unnecessary computation by making it conditional:
if(DEBUG) {
debug(new CryptoMiner());
}
(more likely to be used as a one-liner though: DEBUG && debug(…)
)
Interesting approach 👌 @tbse would that satisfy your use case? |
this might be useful for debugging, but also for recreating the corresponding configuration elsewhere (e.g. independent test cases, migrating away from faucet etc.)
3e9a3cd
to
a4b1278
Compare
(sample below)
use cases:
sample output