Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setName(name?: string | null) {
if (CONFIG.logPath) {
this._path = `${CONFIG.logPath}${name ? `/${name}` : ""}`;
}
this._logger = winston.createLogger({
transports: [
this._path ? createFileTransport(this._path) : createConsoleTransport()
]
});
}
import winston from "winston";
import { CONFIG } from "@qawolf/config";
const transports = [];
const formatPrint = winston.format.printf(
({ level, message, timestamp }) => `${timestamp} ${level}: ${message}`
);
if (CONFIG.logPath) {
transports.push(
new winston.transports.File({
filename: `${CONFIG.logPath}/${Date.now()}.log`,
format: winston.format.combine(winston.format.timestamp(), formatPrint),
level: CONFIG.logLevel || "debug"
})
);
} else {
transports.push(
new winston.transports.Console({
level: CONFIG.logLevel || "error",
format: winston.format.combine(
winston.format.colorize(),
winston.format.timestamp(),
formatPrint
)