-
Notifications
You must be signed in to change notification settings - Fork 109
refactor: log module from logrus to log/slog with multi-handler architecture #1302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: devhaozi <[email protected]>
…tion Co-authored-by: devhaozi <[email protected]>
Co-authored-by: devhaozi <[email protected]>
Co-authored-by: devhaozi <[email protected]>
|
@copilot 然后这些功能现在是不是用不了了? facades.Log().Channel("single").Info(message) facades.Log().Stack([]string{"single", "slack"}).Info(message) Goravel 提供有便捷的链式方式,方便在日志中插入更多有用信息: facades.Log().User("John").Debug(message) 用不了的话得加回去 |
Co-authored-by: devhaozi <[email protected]>
这些功能都还能用:
测试都通过了,包括专门针对这些方法的测试用例(如 |
|
@copilot 还有一点需要重构的:CustomDriver之类的都重构为DriverCustom,DebugLevel之类的都重构为LevelDebug |
Co-authored-by: devhaozi <[email protected]>
|
@copilot 改完不用测试了,提交更改吧 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1302 +/- ##
==========================================
+ Coverage 69.41% 69.99% +0.58%
==========================================
Files 282 282
Lines 16630 16659 +29
==========================================
+ Hits 11543 11660 +117
+ Misses 4596 4511 -85
+ Partials 491 488 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
devhaozi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… level from config, add Entry field tests Co-authored-by: devhaozi <[email protected]>
Addressed in 04da2a6:
|
…again' into copilot/refactor-logrus-to-slog-again
|
@hwbrzzl PTAL |
Co-authored-by: devhaozi <[email protected]>
hwbrzzl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only two nitpicks.
| // getContextValues gets all key-value pairs from the context | ||
| // TODO: This method has a high performance overhead; is it necessary to retain it? | ||
| func getContextValues(ctx any, values map[any]any) { | ||
| contextValues := reflect.Indirect(reflect.ValueOf(ctx)) | ||
| contextKeys := reflect.TypeOf(ctx) | ||
| if contextKeys.Kind() == reflect.Ptr { | ||
| contextKeys = contextKeys.Elem() | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it's required I think.
Co-authored-by: Wenbo Han <[email protected]>
Co-authored-by: devhaozi <[email protected]>
Head branch was pushed to by a user without write access
…, Request, Response Co-authored-by: devhaozi <[email protected]>
hwbrzzl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, LGTM 💯
Closes goravel/goravel#535
Changes Made
Contracts (
contracts/log/)LevelPanic,LevelFatal) defined relative toslog.Level, implementsslog.LevelerinterfaceHookinterface;Logger.Handle()now returnslog.Handler; addedHooktoHandleradapter for backward compatibilityImplementation (
log/)slog-multi.Fanout()for multi-handler supportlogrus_writer.go)IOHandlerandConsoleHandlerimplementinglog.Handler[With]and[Tags]sections when they have entrieslog.Handlerinstead oflogrus.Hook; exportGetLevelFromStringTests
log/logger/handler.go,single.go,daily.golog/entry.goandlog/utils.gousing testify suiteRemoved
log/hook.go,log/formatter/general.gomocks/log/Hook.goDependencies
github.com/samber/slog-multigithub.com/sirupsen/logrus,github.com/rifflock/lfshook💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.