Comparing version 0.1.1 to 0.1.2
@@ -9,2 +9,6 @@ # Change Log | ||
#### 2015-02-23: Steven Velozo | ||
* Finished dumping and reorganizing code | ||
* Finished dumping and reorganizing code | ||
#### 2015-04-03: Steven Velozo | ||
* Documentation and examples | ||
* Added automagic Mongo init (previously you had to explicitly init Mongodbs) |
{ | ||
"name": "fable-log", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A simple logging wrapper.", | ||
@@ -5,0 +5,0 @@ "main": "source/Fable-Log.js", |
118
README.md
@@ -1,2 +0,3 @@ | ||
# Fable Logging | ||
Fable Logging | ||
============= | ||
@@ -6,1 +7,116 @@ A simple package for enabling consistent logging across the Fable package set. This wraps the excellent bunyan logging library. | ||
[![Code Climate](https://codeclimate.com/github/stevenvelozo/fable-log/badges/gpa.svg)](https://codeclimate.com/github/stevenvelozo/fable-log) [![Coverage Status](https://coveralls.io/repos/stevenvelozo/fable-log/badge.svg?branch=master)](https://coveralls.io/r/stevenvelozo/fable-log?branch=master) [![Build Status](https://travis-ci.org/stevenvelozo/fable-log.svg?branch=master)](https://travis-ci.org/stevenvelozo/fable-log) [![Dependency Status](https://david-dm.org/stevenvelozo/fable-log.svg)](https://david-dm.org/stevenvelozo/fable-log) [![devDependency Status](https://david-dm.org/stevenvelozo/fable-log/dev-status.svg)](https://david-dm.org/stevenvelozo/fable-log#info=devDependencies) | ||
Why? | ||
---- | ||
Although I have no interest in writing a logging framework, the effort to setup things like a consistent chain of event logging in an application is not trivial. Want Mongodb logging in your production environment and console logging for unit tests? Bleh more branching. So this is a simple drop-in that uses a standard configuration settings object, and... finds a way. | ||
How to Use This | ||
--------------- | ||
You have to checkout the module from npm: | ||
$ npm install fable-log | ||
Then everything should just work, without configuration, as a bunyan console logger: | ||
var fableLog = require('fable-log').new(); | ||
fableLog.initialize(); | ||
fableLog.trace('Testing object sending to Trace...',{Value:"Unlikely",Status:true}); | ||
fableLog.debug('Testing object sending to Debug...',{Value:"Unlikely",Status:true}); | ||
fableLog.info('Testing object sending to Info...',{Value:"Unlikely",Status:true}); | ||
fableLog.warn('Testing object sending to Warning...',{Value:"Unlikely",Status:true}); | ||
fableLog.error('Testing object sending to Error...',{Value:"Unlikely",Status:true}); | ||
fableLog.fatal('Testing object sending to Fatal...',{Value:"Unlikely",Status:true}); | ||
Which should output the following garbage-looking content to the command-line: | ||
{"name":"Fable","hostname":"Stevens-Mac-Pro.local","pid":58264,"level":10,"Source":"0x532004ec61800000","ver":"0.0.0","datum":{"Value":"Unlikely","Status":true},"msg":"Testing object sending to Trace...","time":"2015-04-03T16:18:36.551Z","v":0} | ||
{"name":"Fable","hostname":"Stevens-Mac-Pro.local","pid":58264,"level":20,"Source":"0x532004ec61800000","ver":"0.0.0","datum":{"Value":"Unlikely","Status":true},"msg":"Testing object sending to Debug...","time":"2015-04-03T16:18:36.551Z","v":0} | ||
{"name":"Fable","hostname":"Stevens-Mac-Pro.local","pid":58264,"level":30,"Source":"0x532004ec61800000","ver":"0.0.0","datum":{"Value":"Unlikely","Status":true},"msg":"Testing object sending to Info...","time":"2015-04-03T16:18:36.551Z","v":0} | ||
{"name":"Fable","hostname":"Stevens-Mac-Pro.local","pid":58264,"level":40,"Source":"0x532004ec61800000","ver":"0.0.0","datum":{"Value":"Unlikely","Status":true},"msg":"Testing object sending to Warning...","time":"2015-04-03T16:18:36.551Z","v":0} | ||
{"name":"Fable","hostname":"Stevens-Mac-Pro.local","pid":58264,"level":50,"Source":"0x532004ec61800000","ver":"0.0.0","datum":{"Value":"Unlikely","Status":true},"msg":"Testing object sending to Error...","time":"2015-04-03T16:18:36.551Z","v":0} | ||
{"name":"Fable","hostname":"Stevens-Mac-Pro.local","pid":58264,"level":60,"Source":"0x532004ec61800000","ver":"0.0.0","datum":{"Value":"Unlikely","Status":true},"msg":"Testing object sending to Fatal...","time":"2015-04-03T16:18:36.551Z","v":0} | ||
But Those Log Entries are Unreadable! | ||
------------- | ||
Want console output to be pretty? Install bunyan globally (may require sudo on some operating systems): | ||
$ npm install -g bunyan | ||
And then pipe your console output through everybodies favorite lumberjack: | ||
$ node MyBestApplicationEver.js | bunyan | ||
[2015-04-03T16:20:43.435Z] TRACE: Fable/58284 on Stevens-Mac-Pro.local: Testing object sending to Trace... (Source=0x532005684ac00000, ver=0.0.0) | ||
datum: { | ||
"Value": "Unlikely", | ||
"Status": true | ||
} | ||
[2015-04-03T16:20:43.435Z] DEBUG: Fable/58284 on Stevens-Mac-Pro.local: Testing object sending to Debug... (Source=0x532005684ac00000, ver=0.0.0) | ||
datum: { | ||
"Value": "Unlikely", | ||
"Status": true | ||
} | ||
[2015-04-03T16:20:43.435Z] INFO: Fable/58284 on Stevens-Mac-Pro.local: Testing object sending to Info... (Source=0x532005684ac00000, ver=0.0.0) | ||
datum: { | ||
"Value": "Unlikely", | ||
"Status": true | ||
} | ||
[2015-04-03T16:20:43.435Z] WARN: Fable/58284 on Stevens-Mac-Pro.local: Testing object sending to Warning... (Source=0x532005684ac00000, ver=0.0.0) | ||
datum: { | ||
"Value": "Unlikely", | ||
"Status": true | ||
} | ||
[2015-04-03T16:20:43.435Z] ERROR: Fable/58284 on Stevens-Mac-Pro.local: Testing object sending to Error... (Source=0x532005684ac00000, ver=0.0.0) | ||
datum: { | ||
"Value": "Unlikely", | ||
"Status": true | ||
} | ||
[2015-04-03T16:20:43.435Z] FATAL: Fable/58284 on Stevens-Mac-Pro.local: Testing object sending to Fatal... (Source=0x532005684ac00000, ver=0.0.0) | ||
datum: { | ||
"Value": "Unlikely", | ||
"Status": true | ||
} | ||
If that isn't exciting enough, on my computer these entries are in __all sorts of rainbow colors__! | ||
So, you're sold on this and want to do something more complex, like say have the logs go in two places: | ||
var fableLogOptions = ( | ||
{ | ||
Product:'Mongoooo', | ||
LogStreams: | ||
[ | ||
{ | ||
level: 'trace', | ||
streamtype:'process.stdout', | ||
}, | ||
{ | ||
level: 'info', | ||
path: './Logs/Fable.log' | ||
} | ||
] | ||
}); | ||
var fableLog = require('fable-log').new(fableLogOptions); | ||
fableLog.initialize(); | ||
fableLog.trace('I really like debugging my code. Here are the fable options!', {Options: fableLogOptions}); | ||
fableLog.info('This is really important info.'); | ||
Which will write the info line to both streams, and the trace line just to the console. | ||
Scalable Functionality | ||
------------ | ||
This logging framework is meant to scale well with log aggregation and multiple data centers, products and versions. There are way more options, the ability to use config files, and other goodies. Features are all covered in the unit tests until the documentation gets completed! | ||
Unit Testing | ||
------------ | ||
You can run the unit tests by executing: | ||
$ npm test | ||
Or you can get the istanbul coverage report by executing: | ||
$ npm run coverage |
@@ -20,2 +20,3 @@ /** | ||
var _MongoStream = false; | ||
var _MongoStreamInitialized = false; | ||
@@ -182,2 +183,4 @@ /** | ||
console.log('***@#$@*#($*@($*@($#@* State: '+_MongoStreamInitialized) | ||
if (!_MongoStream) | ||
@@ -187,4 +190,5 @@ { | ||
} | ||
else | ||
else if (!_MongoStreamInitialized) | ||
{ | ||
_MongoStreamInitialized = true; | ||
var libMongoClient = require('mongodb').MongoClient; | ||
@@ -208,2 +212,6 @@ console.log('Connecting to MongoDB for the Fable Log Mongo provider...'); | ||
} | ||
else | ||
{ | ||
tmpNext(); | ||
} | ||
}; | ||
@@ -210,0 +218,0 @@ |
@@ -55,2 +55,5 @@ /** | ||
} | ||
// Automagically initialize the Mongo streams if they haven't been | ||
_Parameters.initializeMongoStreams(); | ||
}; | ||
@@ -57,0 +60,0 @@ |
@@ -208,2 +208,12 @@ /** | ||
( | ||
'passing in a bad mongoDB parameter', | ||
function(fDone) | ||
{ | ||
var tmpFableLog = require('../source/Fable-Log.js').new({Product:'Mongoooo', LogStreams:[{streamtype:'mongodb'}], MongoDBURL: 'mongodb://baddburl'}); | ||
tmpFableLog.initialize(); | ||
tmpFableLog.initializeMongoStreams(fDone); | ||
} | ||
); | ||
test | ||
( | ||
'passing in the mongoDB parameter', | ||
@@ -225,5 +235,2 @@ function(fDone) | ||
tmpFableLog.info('Test with custom param object: '+tmpFableLog.uuid); | ||
tmpFableLog.info('Test with custom param object: '+tmpFableLog.uuid); | ||
tmpFableLog.info('Test with custom param object: '+tmpFableLog.uuid); | ||
tmpFableLog.info('Test with custom param object: '+tmpFableLog.uuid); | ||
fDone(); | ||
@@ -237,7 +244,9 @@ fNext(); | ||
( | ||
'passing in a bad mongoDB parameter', | ||
'implicit mongodb initialization', | ||
function(fDone) | ||
{ | ||
var tmpFableLog = require('../source/Fable-Log.js').new({Product:'Mongoooo', LogStreams:[{streamtype:'mongodb'}], MongoDBURL: 'mongodb://baddburl'}); | ||
var tmpFableLog = require('../source/Fable-Log.js').new({Product:'Mongoooo', LogStreams:[{streamtype:'process.stdout'},{streamtype:'mongodb'}]}); | ||
tmpFableLog.initialize(); | ||
// We have to do this as a series, so we can ensure the connection is done before we start logging. | ||
tmpFableLog.info('Test without explicit mongo initialization '+tmpFableLog.uuid); | ||
tmpFableLog.initializeMongoStreams(fDone); | ||
@@ -244,0 +253,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39826
1036
121