demnehlog
v0.0.9
Published
A Log Framework, colored console log,telnet client,Mongo Provider for store logs
Downloads
8
Maintainers
Readme
Demneh Logger
Table of Contents
Install
$ npm install demnehlog
Introduction
This is a node.js module for store and show nodejs logs in console,mongo and from telnet. It is written in JavaScript, does not require compiling.
Here is an example on how to use it:
var DemnehLog = require('demnehlog');
var consoleProvider = new DemnehLog.ProviderConsole();
var logger1 = new DemnehLog.Logger([consoleProvider], ['date,title,text']);
logger1.info('tag', 'this is an info log');
logger1.error('tag', 'this is an error');
logger1.fatal('tag', 'this is a fatal error');
logger1.debug('tag', 'this is a debug log');
logger1.warning('tag', 'this is a warning');
Logger
class used to make an object of logger with one or multiple providers.
you can initilize multiple Logger
for diffrent porpuse.In this sample we make a object of Logger
as 'testlogger' with a console provider that show all logs on console screen with 'date,title,text' format, the output is :
Classes
demnehlog has 2 parts as describe below:
Providers
: Providers are the way that you choose to store or show your logs,For instance byProviderMongo
provider you can store your logs in mongoDb permanently, in this version we have 3 providers :ProviderConsole
Shows all logs on console screen.ProviderMongo
Stores logs in mongoDb Database.ProviderTelnet
Sends logs immediately to telnet clients that already connected.Logger
: instance of Logger is a compination or diffrent providers you choose and the log format that the provider must provide.For instance in above example :
var logger2 = new DemnehLog.Logger([consoleProvider], ['date,title,text']);
we set consoleProvider with data,title,text format, the date means when log occours and title meanse which type of message occours (Info,Error,fatal,Debug,warning) and the text means whats happend?. as you can see in the output picture of example1 the logs in like :
(2017/2/6 - 15:15:51.193) Warning | this is a warning
^ ^ ^
| | |
DATE---- TITLE--- TEXT---
you can set any combination you want as provider format , for example :
var logger2 = new DemnehLog.Logger([consoleProvider], ['title,text']);
in this logger1
as you see , logs show without date
ProviderConsole
Comming soon.
ProviderMongo
Comming soon.
ProviderTelnet
Comming soon.
Full Example
Comming soon.
Whats Next
We are going to improve ProviderTelnet
to be more customizable.
Feedback
You can send your feedbacks on https://github.com/kiarsy/DemnehLog also you can join to project for helping improve demnehLog together.