mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-17 17:12:00 +00:00
fix: Remove Moment.js dependency (#28797)
This commit is contained in:
+5
-6
@@ -2,10 +2,8 @@ import assert from "node:assert";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import moment from "moment";
|
||||
import {rimrafSync} from "rimraf";
|
||||
import winston from "winston";
|
||||
|
||||
import * as settings from "./settings";
|
||||
|
||||
const NAMESPACE_SEPARATOR = ":";
|
||||
@@ -31,7 +29,7 @@ class Logger {
|
||||
// What transports to enable
|
||||
this.output = settings.get().advanced.log_output;
|
||||
// Directory to log to
|
||||
const timestamp = moment(Date.now()).format("YYYY-MM-DD.HH-mm-ss");
|
||||
const timestamp = new Date().toISOString().slice(0, 19).replace("T", ".").replace(/:/g, "-");
|
||||
this.directory = settings.get().advanced.log_directory.replace("%TIMESTAMP%", timestamp);
|
||||
const logFilename = settings.get().advanced.log_file.replace("%TIMESTAMP%", timestamp);
|
||||
this.level = settings.get().advanced.log_level;
|
||||
@@ -40,11 +38,12 @@ class Logger {
|
||||
|
||||
assert(settings.LOG_LEVELS.includes(this.level), `'${this.level}' is not valid log_level, use one of '${settings.LOG_LEVELS.join(", ")}'`);
|
||||
|
||||
const timestampFormat = (): string => moment().format(settings.get().advanced.timestamp_format);
|
||||
|
||||
this.logger = winston.createLogger({
|
||||
level: "debug",
|
||||
format: winston.format.combine(winston.format.errors({stack: true}), winston.format.timestamp({format: timestampFormat})),
|
||||
format: winston.format.combine(
|
||||
winston.format.errors({stack: true}),
|
||||
winston.format.timestamp({format: settings.get().advanced.timestamp_format}),
|
||||
),
|
||||
levels: winston.config.syslog.levels,
|
||||
});
|
||||
|
||||
|
||||
@@ -784,7 +784,7 @@
|
||||
"type": "string",
|
||||
"title": "Timestamp format",
|
||||
"requiresRestart": true,
|
||||
"description": "Log timestamp format",
|
||||
"description": "Log timestamp format (see https://github.com/taylorhakes/fecha?tab=readme-ov-file#formatting-tokens for all supported tokens)",
|
||||
"default": "YYYY-MM-DD HH:mm:ss",
|
||||
"examples": ["YYYY-MM-DD HH:mm:ss.SSS"]
|
||||
},
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
"js-yaml": "^4.1.0",
|
||||
"json-stable-stringify-without-jsonify": "^1.0.1",
|
||||
"jszip": "^3.10.1",
|
||||
"moment": "^2.30.1",
|
||||
"mqtt": "^5.14.1",
|
||||
"object-assign-deep": "^0.4.0",
|
||||
"rimraf": "^6.0.1",
|
||||
|
||||
Generated
-8
@@ -41,9 +41,6 @@ importers:
|
||||
jszip:
|
||||
specifier: ^3.10.1
|
||||
version: 3.10.1
|
||||
moment:
|
||||
specifier: ^2.30.1
|
||||
version: 2.30.1
|
||||
mqtt:
|
||||
specifier: ^5.14.1
|
||||
version: 5.14.1
|
||||
@@ -1170,9 +1167,6 @@ packages:
|
||||
resolution: {integrity: sha512-imbHQNRglyaplMmjBLL3V5R6Bfq5oM+ivds3SKgc6oRtzErEnBUUc5No11Z2pilkUvl42gJvi285xTNswcKCMA==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
|
||||
mqtt-packet@9.0.2:
|
||||
resolution: {integrity: sha512-MvIY0B8/qjq7bKxdN1eD+nrljoeaai+qjLJgfRn3TiMuz0pamsIWY2bFODPZMSNmabsLANXsLl4EMoWvlaTZWA==}
|
||||
|
||||
@@ -2614,8 +2608,6 @@ snapshots:
|
||||
|
||||
mixin-deep@2.0.1: {}
|
||||
|
||||
moment@2.30.1: {}
|
||||
|
||||
mqtt-packet@9.0.2:
|
||||
dependencies:
|
||||
bl: 6.1.3
|
||||
|
||||
Reference in New Issue
Block a user