-
Notifications
You must be signed in to change notification settings - Fork 0
borrowed to https://github.com/mikeal/logref/blob/master/main.js#L6-15
this.log is a logref compatible logger, with a bit of enhanced API.
It also have EventEmitter like ability, so you can call on / emit on it, namely used to increase or decrease the padding.
All logs are done against STDERR, letting you stdout for meaningfull value and redirection, should you need to generate output this way.
Log functions take two arguments, a message and a context. For any
other kind of paramters, console.error
is used, so all of the
console format string goodies you're used to work fine.
- msg - The message to show up
- context - The optional context to escape the message against
Retunrns the logger
A simple write method, with formatted message. If msg
is
ommitted, then a single \n
is written.
Returns the logger
Same as log.write()
but automatically appends a \n
at the end
of the message.
Convenience helper to write sucess status, this simply prepends the
message with a gren ✔
.
Each predefined status has its logging method utility, handling
status color and padding before the usual .write()
Example
this.log
.write()
.info('Doing something')
.force('Forcing filepath %s', 'some path')
.conflict('on %s', 'model.js')
.write()
.ok('This is ok');
The list of status and mapping colors
skip yellow
force yellow
create green
invoke bold
conflict red
identical cyan
info grey
Returns the logger
A basic wrapper around cli-table
package, resetting any single
char to empty strings, this is used for aligning options and
arguments without too much Math on our side.
- opts - A list of rows or an Hash of options to pass through cli table.
Returns the table reprensetation