From 128d19e054ee5a8f3125e63c15c0a2804548f295 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期五, 21 十一月 2025 15:21:16 +0800
Subject: [PATCH] gx配置阿里mqtt
---
logger.js | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/logger.js b/logger.js
index 73b720b..6ac80e6 100644
--- a/logger.js
+++ b/logger.js
@@ -2,10 +2,19 @@
require('winston-daily-rotate-file');
const { combine, timestamp, label, printf } = format;
-
+function formatDate(date) {
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ const seconds = String(date.getSeconds()).padStart(2, '0');
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+}
// 自定义日志格式
const myFormat = printf(({ level, message, label, timestamp }) => {
- return `${timestamp} [${label}] ${level}: ${message}`;
+ const formattedTimestamp = formatDate(new Date(timestamp));
+ return `${formattedTimestamp} [${label}] ${level}: ${message}`;
});
// 创建日志记录器
--
Gitblit v1.8.0