morgan-ym-d-log-stream

1.0.2 • Public • Published

morgan-ym-d-log-stream

A stream tool, mainly a plugin for morgan, to save log to file dir/YYYY/M/YYYY-MM-DD.log

Install

npm install morgan-ym-d-log-stream

Usage & Api

var morgan_ym_d_log_stream = require("morgan-ym-d-log-stream");

/*
create a log stream
createLogStream( logDir )
*/
var logStream = morgan_ym_d_log_stream(path.join(__dirname, "log"));

var logger = morgan( 'common', { stream: logStream } );		//creata a morgan function by the stream

/*
write a string
	.write(str)
*/
logStream.write("test, " + (new Date()).toLocaleString() + "\n");

/*
get current log file path
	.currentFilePath()
*/
console.log(logStream.currentFilePath());

Readme

Keywords

Package Sidebar

Install

npm i morgan-ym-d-log-stream

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

4.14 kB

Total Files

4

Last publish

Collaborators

  • adf0001