use dateformat to format date log

This commit is contained in:
2024-03-18 10:33:21 +08:00
parent 25dbad2420
commit c08ffa18b4
3 changed files with 10 additions and 19 deletions

View File

@@ -3,6 +3,8 @@ SteamUser = require('steam-user');
SteamTotp = require('steam-totp'); SteamTotp = require('steam-totp');
fs = require('fs'); fs = require('fs');
winston = require("winston"); winston = require("winston");
dateformat = require('@matteo.collina/dateformat');
logger = winston.createLogger({ logger = winston.createLogger({
level: 'info', level: 'info',
format: winston.format.json(), format: winston.format.json(),
@@ -138,9 +140,7 @@ steamUser.chat.on("friendMessageEcho", (message) => {
* @returns {string} * @returns {string}
*/ */
function dateToString(date) { function dateToString(date) {
let milliseconds = date.getMilliseconds().toString().padStart(3, '0'); return dateformat(date, "yyyy-mm-dd HH:MM:ss.l");
return `${date.toLocaleString()}.${milliseconds}`
} }
function importChatHistory(steamID) { function importChatHistory(steamID) {

22
package-lock.json generated
View File

@@ -9,13 +9,11 @@
"version": "1.0.0", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@matteo.collina/dateformat": "^5.0.1",
"steam-totp": "^2.1.2", "steam-totp": "^2.1.2",
"steam-user": "^5.0.8", "steam-user": "^5.0.8",
"steamcommunity": "^3.48.2", "steamcommunity": "^3.48.2",
"winston": "^3.12.0" "winston": "^3.12.0"
},
"devDependencies": {
"typescript": "^5.4.2"
} }
}, },
"node_modules/@bbob/parser": { "node_modules/@bbob/parser": {
@@ -75,6 +73,11 @@
"resolved": "https://registry.npmjs.org/@doctormckay/user-agents/-/user-agents-1.0.0.tgz", "resolved": "https://registry.npmjs.org/@doctormckay/user-agents/-/user-agents-1.0.0.tgz",
"integrity": "sha512-F+sL1YmebZTY2CnjoR9BXFEULpq7y8dxyLx48LZVa0BSDseXdLG/DtPISfM1iNv1XKCeiBzVNfAT/MOQ69v1Zw==" "integrity": "sha512-F+sL1YmebZTY2CnjoR9BXFEULpq7y8dxyLx48LZVa0BSDseXdLG/DtPISfM1iNv1XKCeiBzVNfAT/MOQ69v1Zw=="
}, },
"node_modules/@matteo.collina/dateformat": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@matteo.collina/dateformat/-/dateformat-5.0.1.tgz",
"integrity": "sha512-BxOmQxcfZxoo+qxI+/lQ28aoh1IpKAiuYLk7sIiCiqOXY9cWfMOwcyJY1xFWPQdHzYlMeeRo0oVABkB3b0ueWw=="
},
"node_modules/@protobufjs/aspromise": { "node_modules/@protobufjs/aspromise": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
@@ -1343,19 +1346,6 @@
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA=="
}, },
"node_modules/typescript": {
"version": "5.4.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz",
"integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/undici-types": { "node_modules/undici-types": {
"version": "5.26.5", "version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",

View File

@@ -10,6 +10,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@matteo.collina/dateformat": "^5.0.1",
"steam-totp": "^2.1.2", "steam-totp": "^2.1.2",
"steam-user": "^5.0.8", "steam-user": "^5.0.8",
"steamcommunity": "^3.48.2", "steamcommunity": "^3.48.2",