mirror of
https://github.com/mathew-kurian/Scribe.js
synced 2025-08-27 12:01:25 +00:00
Update README.md
This commit is contained in:
parent
607169d7f4
commit
17438508a6
1 changed files with 62 additions and 31 deletions
93
README.md
93
README.md
|
@ -48,55 +48,86 @@ Using Sribe is as simple as putting the contents of the Scribe folder into your
|
|||
```
|
||||
\scribe <--- Copy the contents of the "src" folder (which you get from this repo) into "scribe".
|
||||
```
|
||||
3. Add Scribe into the `app.js`
|
||||
----
|
||||
```js
|
||||
var scribe = require('./scribe'); <---- On the very top of your application.
|
||||
```
|
||||
4. Install the required modules
|
||||
----
|
||||
```bat
|
||||
npm install colors
|
||||
npm install moment
|
||||
npm install mkdirp
|
||||
npm install callsite
|
||||
```
|
||||
5. Logging with Scribe
|
||||
----
|
||||
```js
|
||||
// You can use any of the following anywhere Scribe will
|
||||
// both SAVE to file and PRINT to console whatever
|
||||
console.log("[Tagname]Simple message");
|
||||
console.info("[Tagname]Simple message");
|
||||
console.warn("[Tagname]Simple message");
|
||||
console.error("[Tagname]Simple message");
|
||||
console.realtime("[Tagname]Simple message");
|
||||
console.high("[Tagname]Simple message");
|
||||
console.normal("[Tagname]Simple message");
|
||||
console.low("[Tagname]Simple message");
|
||||
```
|
||||
6. Using Scribe and Express
|
||||
----
|
||||
```js
|
||||
// Inside app.js
|
||||
// If you are trying to use it. Just do the following.
|
||||
var scribe = require('./libs/scribe');
|
||||
var scribe = require('./libs/scribe');
|
||||
|
||||
scribe.addLogger("log", true /* Save to file? */, true /* Print to console? */, 'green');
|
||||
scribe.addLogger('error', true, true, 'red');
|
||||
scribe.addLogger('warn', true, true, 'yellow');
|
||||
// Configuration
|
||||
// --------------
|
||||
scribe.configure(function(){
|
||||
scribe.set('app', 'MY_APP_NAME'); // NOTE Best way learn about these settings is
|
||||
scribe.set('logPath', './../logs'); // them out for yourself.
|
||||
scribe.set('defaultTag', 'DEFAULT_TAG');
|
||||
scribe.set('divider', ':::');
|
||||
scribe.set('identation', 5); // Identation before console messages
|
||||
|
||||
scribe.set('maxTagLength', 30); // Any tags that have a length greather than
|
||||
// 30 characters will be ignored
|
||||
|
||||
scribe.set('mainUser', 'root'); // Username of the account which is running
|
||||
// the NodeJS server
|
||||
});
|
||||
|
||||
// Create Loggers
|
||||
// --------------
|
||||
scribe.addLogger("log", true , true, 'green'); // name, save to file, print to console, tag color
|
||||
scribe.addLogger('realtime', true, true, 'underline');
|
||||
scribe.addLogger('high', true, true, 'magenta');
|
||||
scribe.addLogger('normal', true, true, 'white');
|
||||
scribe.addLogger('low', true, true, 'grey');
|
||||
scribe.addLogger('info', true, true, 'cyan');
|
||||
|
||||
// Express.js Output
|
||||
app.use(scribe.express.logger(function(req, res){
|
||||
return true;
|
||||
// Express.js
|
||||
// --------------
|
||||
app.use(scribe.express.logger(function(req, res){ // Express.js access log
|
||||
return true; // if you want to filter out any Express messages
|
||||
}));
|
||||
|
||||
// Enable Web Control Panel
|
||||
app.get('/log', scribe.express.controlPanel);
|
||||
// Control Panel
|
||||
// --------------
|
||||
app.get('/log', scribe.express.controlPanel); // Enable web control panel
|
||||
|
||||
// Basic logging
|
||||
// --------------
|
||||
console.log("[Tagname] Your message"); // [Tagname] Your message
|
||||
console.realtime("[Tagname] Your message"); // [Tagname] Your message
|
||||
console.high("[Tagname] Your message "); // [Tagname] Your message
|
||||
console.normal("[Tagname][]Your message"); // [Tagname] []Your message
|
||||
console.low("[Tagname]Your message"); // [Tagname] Your message
|
||||
|
||||
// Tagging function
|
||||
// ----------------
|
||||
console.t("Tagname").log("Your message"); // [Tagname] Your message
|
||||
console.t("Tagname").log("Your message"); // [Tagname] Your message
|
||||
console.t("Tagname").log("Your message"); // [Tagname] Your message
|
||||
|
||||
// Force use default tag
|
||||
// ---------------------
|
||||
console.t().log("Your message"); // [MY_APP_NAME] Your message
|
||||
|
||||
// Pass in file name
|
||||
// -----------------
|
||||
console.f(__filename).log("Your message"); // [file.js] Your message
|
||||
|
||||
// Auto tagging
|
||||
// -----------------
|
||||
console.log("Your message"); // [invokedFrom.js:25] Your message
|
||||
|
||||
```
|
||||
6. Experimental
|
||||
----
|
||||
```js
|
||||
// Simple visually aided Testing
|
||||
// -----------------
|
||||
console.test("Test name").expect(5).should(5); // Pretty printed test results
|
||||
```
|
||||
Contributors
|
||||
=======
|
||||
|
|
Loading…
Add table
Reference in a new issue