Table of Contents
- Full Example
- Whats Next
$ npm install demnehlog
Here is an example on how to use it:
var DemnehLog = ;var consoleProvider = ;var logger1 = consoleProvider 'date,title,text';logger1;logger1;logger1;logger1;logger1;
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 :
demnehlog has 2 parts as describe below:
Providers: Providers are the way that you choose to store or show your logs,For instance by
ProviderMongoprovider you can store your logs in mongoDb permanently, in this version we have 3 providers :
ProviderConsoleShows all logs on console screen.
ProviderMongoStores logs in mongoDb Database.
ProviderTelnetSends 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 = 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:51193 Warning | this is a warning^ ^ ^| | |DATE---- TITLE--- TEXT---
you can set any combination you want as provider format , for example :
var logger2 = consoleProvider 'title,text';
logger1 as you see , logs show without date
We are going to improve
ProviderTelnet to be more customizable.
You can send your feedbacks on https://github.com/kiarsy/DemnehLog also you can join to project for helping improve demnehLog together.