Open
Description
DraftLog
works. The API is simple. I want to keep it that way, but it might be improved with a few ideas.
Please, contribute by giving your insights, ideas and so on.
[1]
Avoid overriding console._stdout
Can we find a way to NOT put something in the middle of the Stream? Is it possible to 'listen' to data on a Writable stream? If so, that's all we need (we don't ever modify contents anyway)
[2]
Should we 'hook' draft method into console
?
Hooking into console is really cool, but... To specific.
What if the person doesn't uses console
to do logging, but writing to stdout
directly?
In that case, it would cause two problems:
- Draft method would be available only through custom instantiated
Console
. That's a bad requirement to ask developers... (Console is cool, but not a requirement for logging stuff) - If any data get's logged directly into
stdout
, then it would not capture that data.[1]
would fix that, if just in listening mode.
[3]
Ideas for a new (and simpler) API
const DraftLog = require('draftlog')
console.draft = DraftLog(process.stdout[, process.stdin])
// Or save to a custom function maybe
const draft = DraftLog(process.stdout[, process.stdin])
// Would make things easier in case of disabling:
if (PRODUCTION)
const draft = DraftLog();
Metadata
Metadata
Assignees
Labels
No labels