1.1.3 • Published 6 years ago

writelog v1.1.3

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

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 = require("writelog");

// wrap your code block could have some bug to use
try {
  // do some thing
  throw new Error("this is feature, not bug !");
} catch (err) {
  console.error(err);
  writelog("demo", err.stack);
}

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\mid.js:6:9)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:193:16)
    at bootstrap_node.js:617:3

--------------------

API Docs

writelog (name, content, config)

Return : (String) file path

Paramenter

  1. name (String) : name of file. Note, in multi log mode, filename will display with format : name_yyyy-MM-dd_hh-mm-ss.log
  2. 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
  3. config (Object) : (option) for custom your log file
    1. oneFile (String) : turn on / off onePage mode. Default : true
    2. history (String) : number of max history log item can view. Default : 20
    3. dir (String) : to dir to write log file. Default : "./.log/"
    4. 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
1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago