diff --git a/scripts/lib/log.py b/scripts/lib/log.py deleted file mode 100644 index 63bd028..0000000 --- a/scripts/lib/log.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 -# ============================================================================== -# 用途:時間戳與 log 格式的參考實作(Python 版)。對應 /jsc-shared:spec-time-log -# 規範:更新時間一律 Asia/Taipei、固定 yyyy/MM/dd HH:mm:ss(以 -# zoneinfo.ZoneInfo 取得,不硬編 +8 offset,正確處理 DST/歷史時區變更); -# 輸出訊息一律 [時間][階段][等級]: 訊息、一行一則、走 stderr。本檔案不會 -# 被其他 repo 跨 repo 直接 import,純供其他 repo 的腳本對照複製或標註 -# 對應關係(原始寫法見 doc/scripts/worklog/wiki_api.py 的 now_str()/log())。 -# 更新時間:2026/08/11 00:00:00 -# 相依:Python 3 標準庫(zoneinfo、datetime)。 -# ============================================================================== - -import sys -from datetime import datetime -from zoneinfo import ZoneInfo - -TAIPEI = ZoneInfo("Asia/Taipei") - - -def now_taipei(): - """取得台灣時區的 yyyy/MM/dd HH:mm:ss 時間字串。""" - return datetime.now(TAIPEI).strftime("%Y/%m/%d %H:%M:%S") - - -def log(level, message, stage=""): - """輸出統一格式訊息([時間][階段][等級]: 訊息,一行一則),一律走 stderr 不污染 stdout。""" - if stage: - print(f"[{now_taipei()}][{stage}][{level}]: {message}", file=sys.stderr) - else: - print(f"[{now_taipei()}][{level}]: {message}", file=sys.stderr) diff --git a/skills/spec-time-log/SKILL.md b/skills/spec-time-log/SKILL.md index 8f9dc0a..719d11d 100644 --- a/skills/spec-time-log/SKILL.md +++ b/skills/spec-time-log/SKILL.md @@ -7,7 +7,7 @@ description: JSC plugins 共用「時間戳與輸出訊息格式規範」:更 ## 參考實作 -- `shared/scripts/lib/{log.sh,log.py,log.mjs}` 是本規範在 bash/Python/Node(mjs)三種語言下的**唯一參考實作來源**(純參考、不會被其他 repo 跨 repo 呼叫)。其他 repo 的腳本要嘛直接複製其邏輯,要嘛在檔頭註明自己與這份參考實作的對應關係,禁止各自發明第三種時間戳或 log 格式。 +- `shared/scripts/lib/{log.sh,log.mjs}` 是本規範在 bash/Node(mjs)兩種語言下的**唯一參考實作來源**(純參考、不會被其他 repo 跨 repo 呼叫)。其他 repo 的腳本要嘛直接複製其邏輯,要嘛在檔頭註明自己與這份參考實作的對應關係,禁止各自發明第三種時間戳或 log 格式。 ## 更新時間