Skip to content

Commit

Permalink
Libs path
Browse files Browse the repository at this point in the history
  • Loading branch information
Test committed Jan 16, 2018
1 parent 336ee2a commit 70471b3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions libs/logger.js
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;

0 comments on commit 70471b3

Please sign in to comment.