static-console1.0.2 • Public • Published
Keep structure of the messages and log them to any output, using specific plugins.
$ npm install static-console --save --only=production
--only=production to skip installation of testing environment. If you want to test it, don't put this option.
const c = ;
Log message with data
...obj under specified
type - message type name.
null value means that message has regular type.
...obj - parameters that represent the whole message separated by commas
It will output:
This message is printed under specific type PI value: 3.141592653589793
Returns stack trace for your debug needs.
title replaces caption on first line, by default it will be
reset(namespace, displayTitle, params)
Set namespace for all next messages.
namespace - string or undefined. When defined string, represents namespace. When undefined, messages gonna be printed in global namespace.
displayTitle - string with display title for last name.
params - object with other options for last name. Very optional.
Namespace is splitted by
'-' by default) to inherited names, so you can return to parent name without specifying
It will output:
[My module] Welcome to 'module' namespace! [My module » Special task] Initializing awesome... [My module » Task #2] Washing dishes... [My module » Task #2] Preparing table... [My module] I'm done I think 'My module' done with it!
String with character that is used to split namespace to names.
cnamespaceNestingSymbol = '-';// Default valuec;c;// Will output: [first » second » thirdName]
Array containing names data, that are sent to routers. Automatically set by
What are models, outputs and routers?
Separation of these concerns in module makes it possible to keep structure of sending messages to any elements of user interface.
Models - such objects that are used to convert
data, that is used in majority of outputs.
Outputs - such objects that are used to print every message to expected place. You can also think about them as "views".
Routers - such objects that are used to send data to multiple outputs with any models. You can also think about them as "controllers".
By default there is
c.routers.std that is instance of
Standard router has task to send data about every income message to
c.outputs.std that is instance of
StdOutput. That data is converted by
c.models.raw that is instance of
Default solution is bundled with StaticConsole:
FileOutput is not initialized by default, but it must work. So you can print to
c.outputs.std and instance of
FileOutput at same time.
ava --verbose test/MainTest.js
To make tests work, you'll probably need to have local copy of
ava package in your
Make your own solution
If you want to make your own model, output or router class, proceed to source code of module and copy standard solution's directories (
static-console with these plugins: