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

@@ -107,6 +107,13 @@ func Debugv(v any) {
}
}
// Debugfn writes function result into access log.
func Debugfn(fn func() string) {
if shallLog(DebugLevel) {
writeDebug(fn())
}
}
// Debugw writes msg along with fields into the access log.
func Debugw(msg string, fields ...LogField) {
if shallLog(DebugLevel) {
@@ -229,6 +236,13 @@ func Infov(v any) {
}
}
// Infofn writes function result into access log.
func Infofn(fn func() string) {
if shallLog(InfoLevel) {
writeInfo(fn())
}
}
// Infow writes msg along with fields into the access log.
func Infow(msg string, fields ...LogField) {
if shallLog(InfoLevel) {