Skip to content

Instantly share code, notes, and snippets.

@toufiq-austcse
Last active March 22, 2020 17:16
Show Gist options
  • Select an option

  • Save toufiq-austcse/effed2c3b5753b6a7f7f551e85a348ca to your computer and use it in GitHub Desktop.

Select an option

Save toufiq-austcse/effed2c3b5753b6a7f7f551e85a348ca to your computer and use it in GitHub Desktop.
import * as winston from 'winston';
export class LoggerService {
private static myLogger = winston.createLogger({
format: winston.format.json(),
transports: [
new winston.transports.File({filename: process.cwd() + '/project.logs'}),
],
});
static writeErrorLog(msg) {
this.myLogger.error({
timeStamp: new Date().toLocaleString(),
message: msg,
})
}
static writeInfoLog(msg) {
this.myLogger.info({
timeStamp: new Date().toLocaleString(),
message: msg,
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment