Skip to content

chore: log format refactor#78

Merged
soulteary merged 2 commits intomainfrom
ctx-cancel
Jan 6, 2026
Merged

chore: log format refactor#78
soulteary merged 2 commits intomainfrom
ctx-cancel

Conversation

@soulteary
Copy link
Copy Markdown
Owner

No description provided.

Updated the error handling and logging mechanisms to utilize a structured logging format. Replaced traditional logging with a logger package for improved clarity and consistency. Enhanced the logError function to build structured log messages, including additional context such as request IDs and hook IDs, improving the overall error tracking and debugging process.
Enhanced the error handling process by implementing structured logging, which includes additional context such as request IDs and hook IDs. This update improves clarity and consistency in error tracking. Additionally, refactored the makeSureCallable function to support context parameters for better cancellation handling during command validation.
@soulteary soulteary merged commit 5f7eb52 into main Jan 6, 2026
2 checks passed
Comment thread internal/logger/logger.go
writer = io.Discard
} else if logPath != "" {
// 打开日志文件
logFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
args := []any{
"status", status,
"bytes", bytes,
"size", humanize.IBytes(uint64(bytes)),

Check failure

Code scanning / gosec

integer overflow conversion int -> uint64 Error

integer overflow conversion int -> uint64
Comment thread internal/logger/logger.go
func With(args ...any) *slog.Logger {
if DefaultLogger == nil {
// 如果未初始化,使用默认配置初始化
Init(true, false, "", false)

Check warning

Code scanning / gosec

Errors unhandled Warning

Errors unhandled
@soulteary soulteary deleted the ctx-cancel branch January 6, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants