-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Test
committed
Jan 16, 2018
1 parent
336ee2a
commit 70471b3
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import config from "../common/config"; | ||
import winston from "winston"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
import dateFormat from "dateformat"; | ||
|
||
class Logger { | ||
constructor() { | ||
const filename = `/media/dharmatin/Data/nodefier/node-api/logs/test-${dateFormat(new Date(), "yyyymmdd")}.log`; | ||
|
||
return new (winston.Logger)({ | ||
// level: 'debug', | ||
transports: [ | ||
new (winston.transports.File)({ | ||
filename: filename, | ||
json: false, | ||
timestamp: function() { | ||
return dateFormat(new Date(), "yyyy/mm/dd hh:MM:ss"); | ||
}, | ||
formatter: function(options) { | ||
return `${options.timestamp()} [${options.level}]: [${options.message}]` | ||
} | ||
}) | ||
] | ||
}); | ||
} | ||
|
||
static write(level, message) { | ||
const logger = new Logger(); | ||
logger.log(level, message); | ||
} | ||
} | ||
|
||
export default Logger; |