-
Notifications
You must be signed in to change notification settings - Fork 45
4 · API : Scribe
var scribe = require('scribe')();
##scribe(config)
Params :
-
config
: Optional.-
rootPath
: logs folder for LogWriter. Default/logs
-
createDefaultConsole
: Boolean. Iftrue
: create a Console2 instance attached toprocess.console
. Defaulttrue
. See Using Scribe through your modules
-
Return : an object with this properties
console
webPanel
express
LogWriter
Console2
###scribe.console(config, logWriter)
Create a new Console2 instance with LogWriter listening. This is the best way to create a console.
Params :
-
config
-
console
: Optional. Console2 options -
logWriter
: Optional. Boolean|Object. Iffalse
, don't save logs on disk.-
rootPath
: directory where to store logs
-
-
createBasic
: Optional. Boolean.true
to create basic loggers. Defaulttrue
.
-
-
logWriter
: Optional. A custom LogWriter instance to use.
Return : A Console2 instance.
Example :
var console = scribe.console();
var anotherConsole = scribe.console({
console : myConsole2Config,
createBasic : false
});
####Basic loggers
When passing true
as the createBasic
config, you ask ScribeJS to create default loggers to the new console you're builting.
These loggers are :
log()
info()
error()
warning()
dir()
###scribe.webPanel()
Return : an express router
Example : (assuming you have an app
express server)
app.use('/logs', scribe.webPanel());
###scribe.express.logger(console, validate)
Params:
-
console
: Optional. An instance of Console2 with an.info()
logger. If no console provided, Scribe will try to useprocess.console
if it exists. If not, it will throw an error. -
validate
: a filter function that receivereq
andres
as arguments and should returntrue
in order to Scribe to log that request.
Return : a function that log every request
Example :
app.use(scribe.express.logger());
See also : /examples/expressLogger_custom.js
###scribe.LogWriter
LogWriter constructor
Use the constructor to built your own instance of LogWriter. Usefull when you need, by example, to change to full path of a log file.
Default is : [YYYY]/[MM]/[DD_MM_YY].[logger].json
.
You can by example change it to [user]/[logger]/[DD_MMM_YY].[logger].json
. See /examples/logWriter_config.js
.
###scribe.Console2
Console2 constructor
Don't use it directly but use scribe.console()
instead in order to hook LogWriter logic (and others) on the new console.
Copyright © 2014-2015 Scribe.js