jonseymour / idiomatic-console Goto Github PK
View Code? Open in Web Editor NEWA rebindable console API for node.js modules and scripts
Home Page: http://github.com/jonseymour/idiomatic-console
A rebindable console API for node.js modules and scripts
Home Page: http://github.com/jonseymour/idiomatic-console
idiomatic-console suffers from its own composability problem.
One use case for idiomatic-console is to globally rebind the output of the calls to the global console API to some other place.
Ironically, this becomes harder to achieve as more modules use idiomatic-stdio to manage their own console output, because these modules are no longer directly bound to the single global console object.
I am contemplating a good way to fix this. It may involve overloading the function of lock() to configure the console object that is used to back private console objects (currently they are backed by the original, global console object, in future they may be backed by the object established by lock)
It might be useful to support a factory pattern for private console objects.
This would enable the log4j-like configuration approach, for example.
In the case of redirecting console output to a file, is there any way of prefixing the output with a date stamp before it gets written to the file?
Currently idiomatic-console only hooks log, info, warn and error.
Support for hooking other methods should be added.
Currently, the streams used in the .DIAGNOSTICS and .DATA object are the streams present at the point that the idiomatic-console module was initialized. It would probably be better to defer this initialization until the point of the rebind &/or the point of use since something, somewhere may have decided to patch process.stdout and process.stderr with alternatives.
Consider the best way to do this.
The idea is to allow the default bindings used by a node module to be configured externally, as in a log4j configuration file.
Modules would obtain a private console object, and global configuration would determine how that console object behaves. Adapters could be built for popular node.js logging systems.
I am going to make the following changes.
var unlock = console.lock(); try { // application code. } finally { unlock(); }
Define a NULL bindings constant that can be used to suppress all console output.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.