nodejs-simple-log
Overlay to the function console.log
Install
npm install node-simple-log
API
config()
Set templates and colors simple.config(key, value);
var simple = ;simple;simple;simple;
Templates
Posible features:
{time}
complete data like2013-04-20 11:00:26
{parent}
object name{parent.method}
object and method{file}
file with path{file-line-col}
file with path, line and column{file-line}
file with path and line number{rel-file-line-col}
file with path (withoutprocess.cwd()
andprocess.argv[1]
), line and column{rel-file-line}
file with path (withoutprocess.cwd()
andprocess.argv[1]
) and line{rel-file}
file with path (withoutprocess.cwd()
andprocess.argv[1]
){arguments}
if not set arguments are add on end line
Colors
Posible colors and decorations:
reset
underline
black
red
green
yellow
blue
magenta
cyan
gray
white
light-black
light-red
light-green
light-yellow
light-blue
light-magenta
light-cyan
light-white
back-black
back-red
back-green
back-yellow
back-blue
back-magenta
back-cyan
back-white
back-dark
name()
Set name log to next context when use log
var simple = ; // Set config to your own log typesimple;simple;simple;// set context and print logsimplename'myLog';
Standard print methods:
var simple = ; simple;simple;simple;simple;simple;simple;
You can add your log type to global object:
var simple = ;simple { this;}
Example
var simple = ; simple; { simple;}Fooprototype { simple;} { simple;} var obj = ;obj; ;
Result:
[2012-09-30 15:53:44] [-] Some log
[2012-09-30 15:53:44] [new Foo] Some log in constructor
[2012-09-30 15:53:44] [Foo] Some log in Foo.bar()
[2012-09-30 15:53:44] [Bar] Some log in Bar()
See more in example directory