Before logging any data,
you must initialise the library
with an origin string,
using the initialise function:

var fooLog = log.initialise('foo');

The benefit of this step
is that it enables
straightforward searching and filtering
of log files
if you are running a project
where you wish to differentiate
between the origins of different log messages:

var userLog, systemLog;

userLog = log.initialise('user');

systemLog = log.initialise('system');

There is also a second, optional argument to initialise,
the logger function.
If it is undefined,
it defaults to console.log.
However, if you would like to, say,
log messages to a file
rather than the console,
providing a custom logger
enables you to do that:

var userLog, systemLog;

userLog = log.initialise('user', userLogger);

systemLog = log.initialise('system', systemLogger);

functionuserLogger(message){

fs.writeFileSync(logs.user, message +'\n');

}

functionsystemLogger(message){

fs.writeFileSync(logs.system, message +'\n');

}

Regardless of how
you choose to initialise your logger(s),
each one is returned from initialise
as an object with three methods:
info, warn and error.

Each of these methods
takes one argument,
the message that you want to log.
The message will be sent to the appropriate logger function
(or console.log if you used the default),
prefixed with a timestamp,
the log level of the method
(either INFO, WARN or ERROR),
and the origin
that you set in the call to initialise.

The build environment relies on
Node.js,
JSHint,
Mocha,
Chai and
UglifyJS.
Assuming that you already have Node.js and NPM set up,
you just need to run npm install to
install all of the dependencies as listed in package.json.

The unit tests are in test/index.js.
You can run them with the command npm test.
To run the tests in a web browser,
open test/index.html.