Description
Writelog is a lightweight library to auto export log to file.
Why to use
- Catch problem in runtime ( best for server app )
- Easy to view
- Easy to analysis by history
- Easy to work with another team member
Feature
- Write log to file
- Two mode : one file log and multi file log
- Clear log date
- Auto clean up old log
- Auto push up log in Visual Code
How to use
const writelog = ; // wrap your code block could have some bug to usetry // do some thing throw "this is feature, not bug !"; catch err console; ;
Result
your_app/.log/demo.log
12-07-2018 02:55:27 : Error: this is feature not bug ! at Object<anonymous> d:\Workspace\Program\Nodejs\hyron\test\midjs:6:9 at Module at ObjectModule_extensions at Module at at FunctionModule at FunctionModule at at bootstrap_nodejs:617:3 --------------------
API Docs
writelog (name, content, config)
Return : (String) file path
Paramenter
- name (String) : name of file. Note, in multi log mode, filename will display with format : name_yyyy-MM-dd_hh-mm-ss.log
- content (String) : log section data. Suggest is "err.stack" in try catch, and your IDE should install extendsion to jump to error by Ctrl + Click
- config (Object) : (option) for custom your log file
- oneFile (String) : turn on / off onePage mode. Default : true
- history (String) : number of max history log item can view. Default : 20
- dir (String) : to dir to write log file. Default : "./.log/"
- dateFormat (String) : format of date in log file. default : "dd-MM-yyyy hh:mm:ss",
Contact
- Report bug / Request new feature : thangphung.work@gmail.com
- Help me with a cup of coffee : Donate with PayPal