Skip to content

Commit e9d9c3c

Browse files
snomiaoclaude
andauthored
feat: add Winston logger and replace console.log statements (#66)
- Add Winston logger configuration with structured logging - Create logger module with customizable log levels and formatting - Replace console.log statements with Winston logger in key modules - Add comprehensive test suite for logger functionality - Support module-specific loggers with createLogger function - Configure timestamp formatting and metadata handling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 42db8e3 commit e9d9c3c

File tree

8 files changed

+225
-24
lines changed

8 files changed

+225
-24
lines changed

bun.lock

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"use-async-effect": "^2.2.7",
9999
"use-swr-component": "^0.0.7",
100100
"vercel": "^34.4.0",
101+
"winston": "^3.17.0",
101102
"yaml": "^2.5.0",
102103
"zod": "^4.0.5",
103104
"zod-deep-partial": "^1.0.0",
@@ -181,10 +182,14 @@
181182

182183
"@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-x0LvFTekgSX+83TI28Y9wYPUfzrnl2aT5+5QLnO6v7mSJYtEEevuDRN0F0uSHRk1G1IWZC43o00Y0xDDrpBGPQ=="],
183184

185+
"@colors/colors": ["@colors/[email protected]", "", {}, "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA=="],
186+
184187
"@cspotcode/source-map-support": ["@cspotcode/[email protected]", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="],
185188

186189
"@ctrl/mac-address": ["@ctrl/[email protected]", "", {}, "sha512-sYPB1AwHwoSdbKQGfujs7tvFYdfRDfn6yRCAYXrucphTGHc7Ngbzcvcmm1yph3sejGZiXVCFEDjGJJuqVuEvSQ=="],
187190

191+
"@dabh/diagnostics": ["@dabh/[email protected]", "", { "dependencies": { "colorspace": "1.1.x", "enabled": "2.0.x", "kuler": "^2.0.0" } }, "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA=="],
192+
188193
"@discoveryjs/json-ext": ["@discoveryjs/[email protected]", "", {}, "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw=="],
189194

190195
"@edge-runtime/format": ["@edge-runtime/[email protected]", "", {}, "sha512-JQTRVuiusQLNNLe2W9tnzBlV/GvSVcozLl4XZHk5swnRZ/v6jp8TqR8P7sqmJsQqblDZ3EztcWmLDbhRje/+8g=="],
@@ -635,6 +640,8 @@
635640

636641
"@types/stack-utils": ["@types/[email protected]", "", {}, "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw=="],
637642

643+
"@types/triple-beam": ["@types/[email protected]", "", {}, "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw=="],
644+
638645
"@types/unist": ["@types/[email protected]", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
639646

640647
"@types/webidl-conversions": ["@types/[email protected]", "", {}, "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA=="],
@@ -839,6 +846,8 @@
839846

840847
"ast-types-flow": ["[email protected]", "", {}, "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ=="],
841848

849+
"async": ["[email protected]", "", {}, "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA=="],
850+
842851
"async-function": ["[email protected]", "", {}, "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA=="],
843852

844853
"async-listen": ["[email protected]", "", {}, "sha512-CcEtRh/oc9Jc4uWeUwdpG/+Mb2YUHKmdaTf0gUr7Wa+bfp4xx70HOb3RuSTJMvqKNB1TkdTfjLdrcz2X4rkkZA=="],
@@ -977,6 +986,8 @@
977986

978987
"colorette": ["[email protected]", "", {}, "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w=="],
979988

989+
"colorspace": ["[email protected]", "", { "dependencies": { "color": "^3.1.3", "text-hex": "1.0.x" } }, "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w=="],
990+
980991
"combined-stream": ["[email protected]", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
981992

982993
"comma-separated-tokens": ["[email protected]", "", {}, "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg=="],
@@ -1177,6 +1188,8 @@
11771188

11781189
"emotion": ["[email protected]", "", { "dependencies": { "babel-plugin-emotion": "^10.0.27", "create-emotion": "^10.0.27" } }, "sha512-2xdDzdWWzue8R8lu4G76uWX5WhyQuzATon9LmNeCy/2BHVC6dsEpfhN1a0qhELgtDVdjyEA6J8Y/VlI5ZnaH0g=="],
11791190

1191+
"enabled": ["[email protected]", "", {}, "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ=="],
1192+
11801193
"encoding": ["[email protected]", "", { "dependencies": { "iconv-lite": "^0.6.2" } }, "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A=="],
11811194

11821195
"end-of-stream": ["[email protected]", "", { "dependencies": { "once": "~1.3.0" } }, "sha512-EoulkdKF/1xa92q25PbjuDcgJ9RDHYU2Rs3SCIvs2/dSQ3BpmxneNHmA/M7fe60M3PrV7nNGTTNbkK62l6vXiQ=="],
@@ -1339,6 +1352,8 @@
13391352

13401353
"fdir": ["[email protected]", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w=="],
13411354

1355+
"fecha": ["[email protected]", "", {}, "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw=="],
1356+
13421357
"file-entry-cache": ["[email protected]", "", { "dependencies": { "flat-cache": "^3.0.4" } }, "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg=="],
13431358

13441359
"file-saver": ["[email protected]", "", {}, "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="],
@@ -1357,6 +1372,8 @@
13571372

13581373
"flatted": ["[email protected]", "", {}, "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg=="],
13591374

1375+
"fn.name": ["[email protected]", "", {}, "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw=="],
1376+
13601377
"follow-redirects": ["[email protected]", "", {}, "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ=="],
13611378

13621379
"for-each": ["[email protected]", "", { "dependencies": { "is-callable": "^1.2.7" } }, "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg=="],
@@ -1685,6 +1702,8 @@
16851702

16861703
"keyv-cached-with": ["[email protected]", "", { "peerDependencies": { "keyv": "^4.5.4", "typescript": "^5.4.5" } }, "sha512-vewILq++SRMUyPkhmd3U5CME9V+erYTvzd7KPrxQ32B8NRiXhatY8g+J8ygesPcgS4xYIkz4KxSldK6fOtzTrg=="],
16871704

1705+
"kuler": ["[email protected]", "", {}, "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A=="],
1706+
16881707
"language-subtag-registry": ["[email protected]", "", {}, "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ=="],
16891708

16901709
"language-tags": ["[email protected]", "", { "dependencies": { "language-subtag-registry": "^0.3.20" } }, "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA=="],
@@ -1715,6 +1734,8 @@
17151734

17161735
"log-update": ["[email protected]", "", { "dependencies": { "ansi-escapes": "^7.0.0", "cli-cursor": "^5.0.0", "slice-ansi": "^7.1.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" } }, "sha512-9ie8ItPR6tjY5uYJh8K/Zrv/RMZ5VOlOWvtZdEHYSTFKZfIBPQa9tOAEeAWhd+AnIneLJ22w5fjOYtoutpWq5w=="],
17171736

1737+
"logform": ["[email protected]", "", { "dependencies": { "@colors/colors": "1.6.0", "@types/triple-beam": "^1.3.2", "fecha": "^4.2.0", "ms": "^2.1.1", "safe-stable-stringify": "^2.3.1", "triple-beam": "^1.3.0" } }, "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ=="],
1738+
17181739
"loglevel": ["[email protected]", "", {}, "sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg=="],
17191740

17201741
"longest-streak": ["[email protected]", "", {}, "sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g=="],
@@ -1965,6 +1986,8 @@
19651986

19661987
"once": ["[email protected]", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
19671988

1989+
"one-time": ["[email protected]", "", { "dependencies": { "fn.name": "1.x.x" } }, "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g=="],
1990+
19681991
"onetime": ["[email protected]", "", { "dependencies": { "mimic-fn": "^2.1.0" } }, "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg=="],
19691992

19701993
"open": ["[email protected]", "", { "dependencies": { "default-browser": "^5.2.1", "define-lazy-prop": "^3.0.0", "is-inside-container": "^1.0.0", "wsl-utils": "^0.1.0" } }, "sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA=="],
@@ -2205,6 +2228,8 @@
22052228

22062229
"safe-regex-test": ["[email protected]", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "is-regex": "^1.2.1" } }, "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw=="],
22072230

2231+
"safe-stable-stringify": ["[email protected]", "", {}, "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA=="],
2232+
22082233
"safer-buffer": ["[email protected]", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
22092234

22102235
"scheduler": ["[email protected]", "", {}, "sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA=="],
@@ -2289,6 +2314,8 @@
22892314

22902315
"stable-hash": ["[email protected]", "", {}, "sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA=="],
22912316

2317+
"stack-trace": ["[email protected]", "", {}, "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg=="],
2318+
22922319
"stack-utils": ["[email protected]", "", { "dependencies": { "escape-string-regexp": "^2.0.0" } }, "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ=="],
22932320

22942321
"stat-mode": ["[email protected]", "", {}, "sha512-QjMLR0A3WwFY2aZdV0okfFEJB5TRjkggXZjxP3A1RsWsNHNu3YPv8btmtc6iCFZ0Rul3FE93OYogvhOUClU+ng=="],
@@ -2373,6 +2400,8 @@
23732400

23742401
"terser-webpack-plugin": ["[email protected]", "", { "dependencies": { "@jridgewell/trace-mapping": "^0.3.25", "jest-worker": "^27.4.5", "schema-utils": "^4.3.0", "serialize-javascript": "^6.0.2", "terser": "^5.31.1" }, "peerDependencies": { "webpack": "^5.1.0" } }, "sha512-vkZjpUjb6OMS7dhV+tILUW6BhpDR7P2L/aQSAv+Uwk+m8KATX9EccViHTJR2qDtACKPIYndLGCyl3FMo+r2LMw=="],
23752402

2403+
"text-hex": ["[email protected]", "", {}, "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="],
2404+
23762405
"text-table": ["[email protected]", "", {}, "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw=="],
23772406

23782407
"thenify": ["[email protected]", "", { "dependencies": { "any-promise": "^1.0.0" } }, "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw=="],
@@ -2399,6 +2428,8 @@
23992428

24002429
"trim-lines": ["[email protected]", "", {}, "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg=="],
24012430

2431+
"triple-beam": ["[email protected]", "", {}, "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg=="],
2432+
24022433
"trough": ["[email protected]", "", {}, "sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw=="],
24032434

24042435
"trpc-openapi": ["[email protected]", "", { "dependencies": { "co-body": "^6.1.0", "h3": "^1.6.4", "lodash.clonedeep": "^4.5.0", "node-mocks-http": "^1.12.2", "openapi-types": "^12.1.1", "zod-to-json-schema": "^3.21.1" }, "peerDependencies": { "@trpc/server": "^10.0.0", "zod": "^3.14.4" } }, "sha512-pfYoCd/3KYXWXvUPZBKJw455OOwngKN/6SIcj7Yit19OMLJ+8yVZkEvGEeg5wUSwfsiTdRsKuvqkRPXVSwV7ew=="],
@@ -2545,6 +2576,10 @@
25452576

25462577
"widest-line": ["[email protected]", "", { "dependencies": { "string-width": "^7.0.0" } }, "sha512-c9bZp7b5YtRj2wOe6dlj32MK+Bx/M/d+9VB2SHM1OtsUHR0aV0tdP6DWh/iMt0kWi1t5g1Iudu6hQRNd1A4PVA=="],
25472578

2579+
"winston": ["[email protected]", "", { "dependencies": { "@colors/colors": "^1.6.0", "@dabh/diagnostics": "^2.0.2", "async": "^3.2.3", "is-stream": "^2.0.0", "logform": "^2.7.0", "one-time": "^1.0.0", "readable-stream": "^3.4.0", "safe-stable-stringify": "^2.3.1", "stack-trace": "0.0.x", "triple-beam": "^1.3.0", "winston-transport": "^4.9.0" } }, "sha512-DLiFIXYC5fMPxaRg832S6F5mJYvePtmO5G9v9IgUFPhXm9/GkXarH/TUrBAVzhTCzAj9anE/+GjrgXp/54nOgw=="],
2580+
2581+
"winston-transport": ["[email protected]", "", { "dependencies": { "logform": "^2.7.0", "readable-stream": "^3.6.2", "triple-beam": "^1.3.0" } }, "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A=="],
2582+
25482583
"word-wrap": ["[email protected]", "", {}, "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA=="],
25492584

25502585
"wrap-ansi": ["[email protected]", "", { "dependencies": { "ansi-styles": "^6.2.1", "string-width": "^7.0.0", "strip-ansi": "^7.1.0" } }, "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q=="],
@@ -2675,6 +2710,8 @@
26752710

26762711
"cli-truncate/slice-ansi": ["[email protected]", "", { "dependencies": { "ansi-styles": "^6.0.0", "is-fullwidth-code-point": "^4.0.0" } }, "sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ=="],
26772712

2713+
"colorspace/color": ["[email protected]", "", { "dependencies": { "color-convert": "^1.9.3", "color-string": "^1.6.0" } }, "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA=="],
2714+
26782715
"cosmiconfig/path-type": ["[email protected]", "", {}, "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw=="],
26792716

26802717
"cosmiconfig/yaml": ["[email protected]", "", {}, "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg=="],
@@ -2927,6 +2964,8 @@
29272964

29282965
"ajv-keywords/ajv/json-schema-traverse": ["[email protected]", "", {}, "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="],
29292966

2967+
"colorspace/color/color-convert": ["[email protected]", "", { "dependencies": { "color-name": "1.1.3" } }, "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg=="],
2968+
29302969
"edge-runtime/pretty-ms/parse-ms": ["[email protected]", "", {}, "sha512-kHt7kzLoS9VBZfUsiKjv43mr91ea+U05EyKkEtqp7vNbHxmaVuEqN7XxeEVnGrMtYOAxGrDElSi96K7EgO1zCA=="],
29312970

29322971
"eslint/chalk/ansi-styles": ["[email protected]", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="],
@@ -3019,6 +3058,8 @@
30193058

30203059
"@vercel/node/node-fetch/whatwg-url/webidl-conversions": ["[email protected]", "", {}, "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="],
30213060

3061+
"colorspace/color/color-convert/color-name": ["[email protected]", "", {}, "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="],
3062+
30223063
"git-diff/chalk/ansi-styles/color-convert": ["[email protected]", "", { "dependencies": { "color-name": "1.1.3" } }, "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg=="],
30233064

30243065
"git-diff/chalk/supports-color/has-flag": ["[email protected]", "", {}, "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw=="],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
"use-async-effect": "^2.2.7",
148148
"use-swr-component": "^0.0.7",
149149
"vercel": "^34.4.0",
150+
"winston": "^3.17.0",
150151
"yaml": "^2.5.0",
151152
"zod": "^4.0.5",
152153
"zod-deep-partial": "^1.0.0",

src/GithubActionUpdateTask/updateGithubActionTask.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ import DIE from "@snomiao/die";
22
import fastDiff from "fast-diff";
33
import { readFile } from "fs/promises";
44
import sha256 from "sha256";
5-
import yaml from "yaml";
65
import { createPR } from "../createGithubPullRequest";
76
import { gh } from "../gh";
7+
import { createLogger } from "../logger";
88
import { parsePullUrl } from "../parsePullUrl";
99
import { GithubActionUpdateTask } from "./GithubActionUpdateTask";
1010
import { updateGithubActionPrepareBranch } from "./updateGithubActionPrepareBranch";
1111

12+
const logger = createLogger("updateGithubActionTask");
13+
1214
export const referenceActionContent = await readFile("./templates/publish.yaml", "utf8");
1315
export const referencePullRequestMessage = await readFile("./templates/tasks/GithubActionUpdatePR.md", "utf8");
1416
export const referenceActionContentHash = sha256(referenceActionContent); // check if target publish.yaml already latest
15-
console.log("referenceActionContentHash", referenceActionContentHash);
17+
logger.debug("referenceActionContentHash", { referenceActionContentHash });
1618

1719
// for debug only
1820
export const testUpdatedPublishYaml = await readFile(import.meta.dir + "/test-updated-publish.yml", "utf8");
@@ -21,9 +23,9 @@ if (import.meta.main) {
2123
// const repo = "https://github.com/aigc-apps/VideoX-Fun";
2224
const repo = "https://github.com/FuouM/ComfyUI-MatAnyone";
2325
await resetErrorForGithubActionUpdateTask(repo);
24-
console.log(await updateGithubActionTask(repo));
25-
console.log(await GithubActionUpdateTask.findOne({ repo }));
26-
console.log("done");
26+
logger.info("Task result", { result: await updateGithubActionTask(repo) });
27+
logger.info("Task status", { task: await GithubActionUpdateTask.findOne({ repo }) });
28+
logger.info("done");
2729
}
2830

2931
/**
@@ -42,7 +44,7 @@ export async function updateGithubActionTask(repoUrl: string) {
4244

4345
// check if already up to date
4446
if (referenceActionContentHash !== task.branchVersionHash) {
45-
console.log("[updateGithubActionTask] AI Suggesting PR for", repoUrl);
47+
logger.info("AI Suggesting PR", { repoUrl });
4648
// make branch
4749
const {
4850
hash,
@@ -70,16 +72,21 @@ export async function updateGithubActionTask(repoUrl: string) {
7072
{ upsert: true, returnDocument: "after" },
7173
)!;
7274
Object.assign(task, updatedTask);
73-
console.debug(
74-
yaml.stringify({ repo: repoUrl, hash, forkedBranchUrl, commitMessage, pullRequestMessage, branchDiffResult }),
75-
);
75+
logger.debug("Branch update details", {
76+
repo: repoUrl,
77+
hash,
78+
forkedBranchUrl,
79+
commitMessage,
80+
pullRequestMessage,
81+
branchDiffResult,
82+
});
7683
}
7784

7885
if (
7986
referenceActionContentHash !== task.pullRequestVersionHash &&
8087
referenceActionContentHash === task.approvedBranchVersionHash
8188
) {
82-
console.log("[updateGithubActionTask] Creating PR for", repoUrl);
89+
logger.info("Creating PR", { repoUrl });
8390
const [src, branch] = task.forkedBranchUrl!.split("/tree/");
8491
const pullRequestUrl = await createPR({
8592
branch: branch || DIE("missing branch in forkedBranchUrl: " + task.forkedBranchUrl),
@@ -111,9 +118,9 @@ export async function updateGithubActionTask(repoUrl: string) {
111118
const { owner, repo, pull_number } = parsePullUrl(task.pullRequestUrl);
112119
const { data: pr } = await gh.pulls.get({ owner, repo, pull_number });
113120
const pullRequestStatus = pr.merged_at ? "MERGED" : pr.closed_at ? "CLOSED" : "OPEN";
114-
console.log(`[updateGithubActionTask] got ${pullRequestStatus} status in ${task.pullRequestUrl}`);
121+
logger.info("PR status retrieved", { pullRequestStatus, url: task.pullRequestUrl });
115122
const pullRequestCommentsCount = pr.comments;
116-
console.log(`[updateGithubActionTask] got ${pullRequestCommentsCount} comments in ${task.pullRequestUrl}`);
123+
logger.info("PR comments count", { pullRequestCommentsCount, url: task.pullRequestUrl });
117124

118125
const rawComments =
119126
pullRequestCommentsCount === 0
@@ -145,7 +152,9 @@ export async function updateGithubActionTask(repoUrl: string) {
145152
})
146153
.join("\n");
147154
// filter out new pr comments, maybe send to slack
148-
console.log(newCommentsMessage);
155+
if (newCommentsMessage) {
156+
logger.debug("New PR comments", { newCommentsMessage });
157+
}
149158

150159
const updatedTask = await GithubActionUpdateTask.findOneAndUpdate(
151160
{ repo: repoUrl },
@@ -173,7 +182,7 @@ export async function updateGithubActionTask(repoUrl: string) {
173182
// { upsert: true, returnDocument: "after" },
174183
// );
175184
// }
176-
console.log("[updateGithubActionTask] Updated: " + repoUrl);
185+
logger.info("Task updated", { repoUrl });
177186
}
178187
export async function resetErrorForGithubActionUpdateTask(repo: string) {
179188
await GithubActionUpdateTask.findOneAndDelete({ repo });

0 commit comments

Comments
 (0)