docs(release-cleanup): 補齊 CI workflow 註解、統一日誌格式並重建 README
- .gitea/workflows/ci.yaml、cd.yaml:新增用途/更新日期區塊與逐行註解(指令邏輯不變) - app/index.js:日誌統一為 [等級][台灣時間]: 訊息(新增 timestamp helper,INF/WRN/ERR;行為、控制流、exit code、stdout/stderr 皆等價) - README.md:重建專案列表三表/功能列表/使用範例,新增日誌格式說明與 timestamp 功能 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
cee5b2f67f
commit
15381d07a7
+22
-8
@@ -25,44 +25,58 @@ function section(title) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 [INFO] 前綴將一般資訊訊息輸出到 stdout。
|
||||
* 取得目前 Asia/Taipei 時區的時間字串,格式為 `yyyy/MM/dd HH:mm:ss`。
|
||||
* 使用 Node 內建 Intl(`toLocaleString('sv-SE')` 天生輸出 24 小時制
|
||||
* `YYYY-MM-DD HH:mm:ss`,再把 `-` 換成 `/`),不需額外相依。
|
||||
*
|
||||
* @returns {string} 例如 `2026/06/30 16:53:06`。
|
||||
*/
|
||||
function timestamp() {
|
||||
return new Date()
|
||||
.toLocaleString('sv-SE', { timeZone: 'Asia/Taipei' })
|
||||
.replace(/-/g, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 `[INF][時間]:` 前綴將一般資訊訊息輸出到 stdout(時間為 Asia/Taipei)。
|
||||
*
|
||||
* @param {string} msg 要輸出的訊息內容。
|
||||
* @returns {void}
|
||||
*/
|
||||
function info(msg) {
|
||||
console.log(`[INFO] ${msg}`);
|
||||
console.log(`[INF][${timestamp()}]: ${msg}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 [OK] 前綴將成功訊息輸出到 stdout。
|
||||
* 以 `[INF][時間]:` 前綴將成功訊息輸出到 stdout(時間為 Asia/Taipei)。
|
||||
* 規範等級碼無「成功」,故等級採 INF,成功語意保留於訊息文字。
|
||||
*
|
||||
* @param {string} msg 要輸出的訊息內容。
|
||||
* @returns {void}
|
||||
*/
|
||||
function success(msg) {
|
||||
console.log(`[OK] ${msg}`);
|
||||
console.log(`[INF][${timestamp()}]: ${msg}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 [WARN] 前綴將警告訊息輸出到 stdout。
|
||||
* 以 `[WRN][時間]:` 前綴將警告訊息輸出到 stdout(時間為 Asia/Taipei)。
|
||||
*
|
||||
* @param {string} msg 要輸出的訊息內容。
|
||||
* @returns {void}
|
||||
*/
|
||||
function warn(msg) {
|
||||
console.log(`[WARN] ${msg}`);
|
||||
console.log(`[WRN][${timestamp()}]: ${msg}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 以 [ERR] 前綴將錯誤訊息輸出到 stderr。
|
||||
* 以 `[ERR][時間]:` 前綴將錯誤訊息輸出到 stderr(時間為 Asia/Taipei)。
|
||||
* 僅負責輸出,不會結束程序(是否離開由呼叫端決定)。
|
||||
*
|
||||
* @param {string} msg 要輸出的錯誤訊息內容。
|
||||
* @returns {void}
|
||||
*/
|
||||
function fail(msg) {
|
||||
console.error(`[ERR] ${msg}`);
|
||||
console.error(`[ERR][${timestamp()}]: ${msg}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user