Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

5 · Tips n' Tricks

Mathew Kurian edited this page Dec 25, 2014 · 1 revision

#How logs are saved ?

LogWriter create an history.json file in root folder where it keeps tracks of all logs files created by date. It also creates [logger name].json in root folder for each logger where it saves the logger config. Then LogWriter will save logs in directory according to the output of LogWriter.path().

#Using old console

Scribe overides nothing and doesn't break logging in dependencies. The old NodeJS console is never too far away.

require('scribe')();

var console = process.console;

console.time().log("Logging with Scribe")
global.console.log("Logging the old way")
//in a dependency
console.log("Something") //the old console

See : NodeJS global doc

#Using Scribe through your modules

When running require('scribe')() or require('scribe')({createDefaultConsole : true}) you ask Scribe to attach a fresh console on the NodeJS process variable.

As process is shared accross all modules you required (the whole process), you can use the Console2 instance in sub-modules.

Example :

//main.js
require('scribe')();
var sub = require('./sub.js'); //a sub-module
var console = process.console;

console.tag('Hello world').log("We're in the main file")

sub.something(); //Will use process.console
//sub.js
//don't require scribe, simply link `process.console`
var console = process.console;

module.exports = {
    something : function () {
        console.tag("Hello World", "Sub").log("We're in a submodule");
    }
};

Tip : even if you don't tell scribe to create a default console, you can manually attach a Console2 instance on process.

//main.js
var scribe = require('scribe')({
    createDefaultConsole : false
});
var sub = require('./sub.js'); //a sub-module

var customConsole = scribe.console({  //a new console
    //custom
});

process.customConsole = customConsole; //attach it to process

customConsole('Hello world').log("We're in the main file")

sub.something(); //Will use process.console
//sub.js
//don't require scribe
var console = process.customConsole;

module.exports = {
    something : function () {
        console.tag("Hello World", "Sub").log("We're in a submodule");
    }
};

See :

#Miscellaneous

WebPanel highly depends on LogWriter as it use history.json file to find logs.

WebPanel is RESTfull :

  • on the server side, an express router serves an API and find files on disk
  • on client side, an AngularJS app manage the routing and the data

All the client code is under /static.

Clone this wiki locally