Android Log Cat Inspired Logger for NodeJS
##Installation
$ npm install --save jlogger
A simple logger inspired by Android LogCat for NodeJS.
This logger provides functions like Log.e(), Log.w(), Log.i() and Log.d() as in Android App Development.
The display is as
Source code for screenshot
**Note: Known issues when running with forever.js.
Run with --colors if colors are not showing.
**
##Usage
var Log = require('jlogger');
Log.addGlobalConfig("defaultTag", "defaultTag");
var TAG = "some TAG";
Log.e(TAG, "your msg");
Log.error(TAG, "your msg");
Log.w(TAG, "msg");
Log.warn(TAG, "msg");
Log.i(TAG, "msg");
Log.info(TAG, "msg");
Log.d(TAG, "msg");
Log.d("blue", TAG, "msg");
Log.debug(color, TAG, "msg");
Log.hr(length);
If you want a new instance of the Logger, having different properties from global config use:
var Log = require('jlogger');
var Log2 = new Log.Logger({"defaultTag": "another default tag"});
Log2.e(TAG, "Another instance of logger");
Log.e("Msg with default TAG");
Available customisations
Log.setGlobalConfig({
"defaultTag": "<your default tag name>",
"tagBold": <true/false>,
"hrLength": <length of hr>, //Default length of horizontal line. If not specified then it fits to terminal size
"hrChar": "=", //Draw horizontal line with specified character. Default is "-"
"adaptScreenSize": <true/false>, //If true then hr width will fit the current terminal size
"projectName": "<your project name>", //Display this in your log
"showProjectName": <true/false>, //If false then project name is not printing in log. Default is true
});
Using Log.hr()
Log.hr(length, showTimestamp, color, tag, char);
length: Number Number of characters to draw. Default is set by global Config
showTimeStamp: true/false Whether to show timestamp. Default is false
color: color name Color for the horizontal line
tag: tag tag for hr
char: "=" String with which the hr is to be drawn. (tag parameter should be present, atleast an empty placeholder)
###Sections
You can create a section in your terminal by using Log.section().
Log.section(color, msg, char);
###JSON formatting
No need to stringify the json to display. The module displays it with correct indentation.
var obj = {
name: "Jibin Mathews",
email: "jibinmathews7@gmail.com"
};
Log.e(TAG, obj);
or
Log.d("blue", TAG, obj);
##Release Notes
- Release 1.3.0
- Release 1.2.0
- Added JSON formatting
- Text wrapping (Changed from character based wrapping to word based wrapping)
- Bug fix with setting config
- Release 1.1.0
- Release 1.0.0