mirror of
https://github.com/microsoft/TypeScript-Node-Starter.git
synced 2025-11-08 15:37:24 +00:00
Change Winston logger creation
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user