https://github.com/herenow/simple-logs
A simple methods for console logging with colors and in an organized manner.
https://github.com/herenow/simple-logs
Last synced: 2 months ago
JSON representation
A simple methods for console logging with colors and in an organized manner.
- Host: GitHub
- URL: https://github.com/herenow/simple-logs
- Owner: herenow
- License: gpl-2.0
- Created: 2014-04-08T15:13:32.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-02T08:15:10.000Z (almost 11 years ago)
- Last Synced: 2024-04-24T15:43:02.556Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 234 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
simple-logs
=======Simple logs is a simple method for logging, its straight foward. See the examples below.
There are 4 methods, log.info, log.warn, log.error and log.debug.
For each module simple-logs will be in, you can instanciate a new Log, and pass in a text to prepend to each log, so in this case:
```javascript
var Log = require('simple-logs');var log = new Log('module_name');
//now we have our methods:
//log.info()
//log.warn()
//log.error()
//log.debug()
```Installation
----------
```
npm install simple-logs
```Usage example
----------
* Core.js```javascript
var Log = require('simple-logs');//Every logging method will try to emit an event, you can listen to them as follow.
Log.on('error', function ErrorEvent(log) {
//Do something
});// Setting debug to false, will make log.debug print or emit no events!
Log.setDebug(true); //Defaults to true
```* SomeModule.js
```javascript
var Log = require('simple-logs');var log = new Log('SomeModule');
log.info('this is %s', 'running');
log.warn('failed to log action');
log.error('failed to %s', 'write to buffer');
log.debug('his name was %s', 'john');//I dont recommend doing this, but you can :)
Log.info('this is %s', 'running');
Log.warn('failed to log action');
Log.error('failed to %s', 'write to buffer');
Log.debug('his name was %s', 'john');
```
Authors
---------
- [herenow](https://github.com/herenow)Contribute
----------
If you want to send any contributions, just send me a pull request.