1
0
mirror of https://github.com/microsoft/TypeScript-Node-Starter.git synced 2025-11-08 14:47:28 +00:00

Change Winston logger creation

This commit is contained in:
Peter Blazejewicz
2019-06-22 22:16:55 +02:00
parent 5a11f7e381
commit 01454454c7

View File

@@ -1,16 +1,18 @@
import winston from "winston";
import { Logger } from "winston";
import { Logger, LoggerOptions, transports } from "winston";
const logger = new (Logger)({
transports: [
new (winston.transports.Console)({ level: process.env.NODE_ENV === "production" ? "error" : "debug" }),
new (winston.transports.File)({ filename: "debug.log", level: "debug"})
]
});
const options: LoggerOptions = {
transports: [
new transports.Console({
level: process.env.NODE_ENV === "production" ? "error" : "debug"
}),
new transports.File({ filename: "debug.log", level: "debug" })
]
};
const logger = new Logger(options);
if (process.env.NODE_ENV !== "production") {
logger.debug("Logging initialized at debug level");
logger.debug("Logging initialized at debug level");
}
export default logger;