add Debugfn and Infofn to logx/logc #4595 (#4598)

This commit is contained in:
Devin
2025-01-25 22:21:50 +08:00
committed by GitHub
parent 7d05a4bc93
commit 64e8c94198
5 changed files with 80 additions and 1 deletions

View File

@@ -57,6 +57,11 @@ func (l *richLogger) Debugv(v any) {
l.debug(v)
}
}
func (l *richLogger) Debugfn(fn func() string) {
if shallLog(DebugLevel) {
l.debug(fn())
}
}
func (l *richLogger) Debugw(msg string, fields ...LogField) {
if shallLog(DebugLevel) {
@@ -106,6 +111,12 @@ func (l *richLogger) Infov(v any) {
}
}
func (l *richLogger) Infofn(fn func() string) {
if shallLog(InfoLevel) {
l.info(fn())
}
}
func (l *richLogger) Infow(msg string, fields ...LogField) {
if shallLog(InfoLevel) {
l.info(msg, fields...)