Browse Source

Merge pull request #246 from JazzFisch/fix-log-folder

Write homepage.log into config folder
Jason Fischer 2 năm trước cách đây
mục cha
commit
ab631fa26e
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      src/utils/logger.js

+ 5 - 1
src/utils/logger.js

@@ -1,5 +1,9 @@
+import { join } from "path";
+
 import winston from "winston";
 import winston from "winston";
 
 
+const configPath = join(process.cwd(), "config");
+
 function messageFormatter(logInfo) {
 function messageFormatter(logInfo) {
   if (logInfo.stack) {
   if (logInfo.stack) {
     return `[${logInfo.timestamp}] ${logInfo.level}: ${logInfo.stack}`;
     return `[${logInfo.timestamp}] ${logInfo.level}: ${logInfo.stack}`;
@@ -33,7 +37,7 @@ const logger = winston.createLogger({
 
 
     new winston.transports.File({
     new winston.transports.File({
       format: fileFormat,
       format: fileFormat,
-      filename: 'homepage.log',
+      filename: `${configPath}/logs/homepage.log`,
       handleExceptions: true,
       handleExceptions: true,
       handleRejections: true
       handleRejections: true
     }),
     }),