mirror of
https://github.com/mathew-kurian/Scribe.js
synced 2025-08-14 13:51:22 +00:00
Updating README
This commit is contained in:
parent
1ed172708b
commit
83d09e6b71
1 changed files with 144 additions and 17 deletions
161
README.md
161
README.md
|
@ -1,26 +1,153 @@
|
||||||
# Scribe.js
|

|
||||||
|
=======
|
||||||
|
**Lightweight NodeJS Logging**
|
||||||
|
Overview
|
||||||
|
=======
|
||||||
Unlike many of the libraries out there, Scribe.js allows logging on multiple files and is divided into folders by date. And it is possibly the easiest logging you can implement. And it does everything you need a basic logger to do.
|
Unlike many of the libraries out there, Scribe.js allows logging on multiple files and is divided into folders by date. And it is possibly the easiest logging you can implement. And it does everything you need a basic logger to do.
|
||||||
|
- Save messages into log files organized by user, date, and type
|
||||||
|
- Print messages into console using colors indicating level of importance
|
||||||
|
|
||||||
## Getting Started
|
Output Methods (Web | Console | File)
|
||||||
Install the module with: `npm install scribe-js`
|
=======
|
||||||
|
Method#Web - Select Date
|
||||||
|
---
|
||||||
|

|
||||||
|
Method#Web - Select Log Type
|
||||||
|
---
|
||||||
|

|
||||||
|
Method#Web - View Logs
|
||||||
|
---
|
||||||
|

|
||||||
|
Method#Console - Command Prompt
|
||||||
|
---
|
||||||
|

|
||||||
|
Method#File - File
|
||||||
|
---
|
||||||
|

|
||||||
|
Method#File - Directory Layout
|
||||||
|
---
|
||||||
|

|
||||||
|
|
||||||
```javascript
|
How to use Scribe.js
|
||||||
var scribe = require('scribe');
|
=======
|
||||||
|
Using Sribe is as simple as putting the contents of the Scribe folder into your root NodeJS folder. Note: What I am about to show you is the simplest way to use Scribe.js. Since this library (if you can even call it that), is not insave at all, and it should be very easy to adjust to your liking.
|
||||||
|
|
||||||
|
1. Make a Scribe directory
|
||||||
|
----
|
||||||
```
|
```
|
||||||
|
\root
|
||||||
|
\node_modules
|
||||||
|
\scribe <--- Make a folder named "scribe"
|
||||||
|
\views
|
||||||
|
\controllers
|
||||||
|
\bunchOfOtherFolder...
|
||||||
|
app.js
|
||||||
|
```
|
||||||
|
2. Add Scribe into this folder
|
||||||
|
----
|
||||||
|
```
|
||||||
|
\node_modules\scribe <--- Copy the contents of the "src" folder (which you get from this repo) into "scribe".
|
||||||
|
```
|
||||||
|
4. Install the required modules
|
||||||
|
----
|
||||||
|
```bat
|
||||||
|
npm install colors
|
||||||
|
npm install moment
|
||||||
|
npm install mkdirp
|
||||||
|
npm install callsite
|
||||||
|
npm install express // if you want to enable the visual web view
|
||||||
|
```
|
||||||
|
5. Logging with Scribe
|
||||||
|
----
|
||||||
|
```js
|
||||||
|
var scribe = require('scribe');
|
||||||
|
|
||||||
## Documentation
|
// Configuration
|
||||||
_(Coming soon)_
|
// --------------
|
||||||
|
scribe.configure(function(){
|
||||||
|
scribe.set('app', 'MY_APP_NAME'); // NOTE Best way learn about these settings is
|
||||||
|
scribe.set('logPath', './logs'); // Doublecheck // 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
|
||||||
|
});
|
||||||
|
|
||||||
## Examples
|
// Create Loggers
|
||||||
_(Coming soon)_
|
// --------------
|
||||||
|
scribe.addLogger("log", true , true, 'green'); // (name, save to file, print to console,
|
||||||
|
scribe.addLogger('realtime', true, true, 'underline'); // tag color)
|
||||||
|
scribe.addLogger('high', true, true, 'magenta');
|
||||||
|
scribe.addLogger('normal', true, true, 'white');
|
||||||
|
scribe.addLogger('low', true, true, 'grey');
|
||||||
|
scribe.addLogger('info', true, true, 'cyan');
|
||||||
|
|
||||||
## Contributing
|
// Express.js
|
||||||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
|
// WARNING: ExpressJS must be installed for this to work
|
||||||
|
// You also need to start an ExpressJS server in order for
|
||||||
|
// this to work.
|
||||||
|
// --------------
|
||||||
|
app.use(scribe.express.logger(function(req, res){ // Express.js access log
|
||||||
|
return true; // Filter out any Express messages
|
||||||
|
}));
|
||||||
|
|
||||||
## Release History
|
// Control Panel
|
||||||
_(Nothing yet)_
|
// WARNING: ExpressJS must be installed for this to work
|
||||||
|
// You also need to start an ExpressJS server in order for
|
||||||
|
// this to work.
|
||||||
|
// --------------
|
||||||
|
app.get('/log', scribe.express.controlPanel()); // Enable web control panel
|
||||||
|
|
||||||
## License
|
// Basic logging
|
||||||
Copyright (c) 2014 Mathew Kurian
|
// --------------
|
||||||
Licensed under the MIT license.
|
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
|
||||||
|
|
||||||
|
// Tag Scoping
|
||||||
|
// -----------
|
||||||
|
(function(console){
|
||||||
|
|
||||||
|
console.info("yeeha"); // [scoped-tag] yeeha
|
||||||
|
console.log("yeeha"); // [scoped-tag] yeeha
|
||||||
|
|
||||||
|
})(console.t('scoped-tag'));
|
||||||
|
|
||||||
|
```
|
||||||
|
6. Experimental
|
||||||
|
----
|
||||||
|
```js
|
||||||
|
// Simple Testing
|
||||||
|
// --------------
|
||||||
|
console.test("Test name").should(5).be(5); // Pretty printed test results
|
||||||
|
```
|
||||||
|
Contributors
|
||||||
|
=======
|
||||||
|
```
|
||||||
|
bluejamesbond
|
||||||
|
```
|
Loading…
Add table
Reference in a new issue