Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init 初始化全域 slog.Default logger,同時輸出 JSON 格式到檔案與 text 格式到 stderr。 環境變數 FOURX_LOG_LEVEL 會覆蓋 cfg.Level。若無法建立 log 目錄或檔案, 不阻擋程式啟動,改為僅輸出到 stderr。
func Middleware ¶
Middleware 回傳 HTTP request logging 的中介層。 每個 request 記錄 method、path、status code 與處理時間(毫秒)。 2xx/3xx 用 slog.Info、4xx 用 slog.Warn、5xx 用 slog.Error。
func ParseLevel ¶
ParseLevel 將字串轉為對應的 slog.Level。 支援 debug、info、warn、error(不分大小寫),無法辨識時回傳 slog.LevelInfo。
Types ¶
Click to show internal directories.
Click to hide internal directories.