-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patched some better formatting into it..
- Loading branch information
Christian Froehlingsdorf
committed
Jun 30, 2016
1 parent
a8aa03b
commit ed86653
Showing
8 changed files
with
237 additions
and
49 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
# log4bro (nodejs logger) | ||
- the (only) one usable logger | ||
|
||
- log4bro makes it hassle free to have compliant microservice log behaviour | ||
- just require & init and log via global variable in a few seconds | ||
- you can run in production mode to automatically switch log-levels | ||
- you can run in dockerMode to stop logfile writing and change output to json fields | ||
- you can attach some extra fields to json logs so that they are also loved by your ELK stack and your sysops | ||
- node + docker + log4bro = happy you, happy ELK stack and happy sysops | ||
|
||
# simple example | ||
|
||
```javascript | ||
|
||
|
@@ -31,4 +39,58 @@ LOG.fatal("bla"); | |
//thats all there is to it.. | ||
``` | ||
|
||
# different example show text & json output | ||
- (just run npm start to run example locally) | ||
|
||
``` | ||
var log4bro = require("log4bro"); | ||
var options = { | ||
"productionMode": false, | ||
"logDir": "logs", | ||
"skipEnhance": true, | ||
"namespace": "", | ||
"silence": false, | ||
"loggerName": "dev", | ||
"dockerMode": false, | ||
"varKey": "MLOG" | ||
}; | ||
var logger = new log4bro(options); | ||
var msg = "ich mache mir sorgen, ob der logger denn noch funktioniert."; | ||
MLOG.trace(msg); | ||
MLOG.debug(msg); | ||
MLOG.info(msg); | ||
MLOG.warn(msg); | ||
MLOG.error(msg); | ||
MLOG.fatal(msg); | ||
console.log(""); | ||
/* json style */ | ||
var options2 = { | ||
"productionMode": true, | ||
"logDir": "logs", | ||
"skipEnhance": true, | ||
"namespace": "", | ||
"silence": false, | ||
"loggerName": "dev", | ||
"dockerMode": true, | ||
"varKey": "JLOG" | ||
}; | ||
var logger2 = new log4bro(options2); | ||
JLOG.trace(msg); | ||
JLOG.debug(msg); | ||
JLOG.info(msg); | ||
JLOG.warn(msg); | ||
JLOG.error(msg); | ||
JLOG.fatal(msg); | ||
``` | ||
|
||
- enjoy.. need help? contact me.. @krystianity or on twitter: @silentleave | ||
- author: Christian Fröhlingsdorf, <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.