|
|
|
@ -86,7 +86,7 @@ func Debugv(v any) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Debugw writes msg along with fields into access log.
|
|
|
|
|
// Debugw writes msg along with fields into the access log.
|
|
|
|
|
func Debugw(msg string, fields ...LogField) {
|
|
|
|
|
if shallLog(DebugLevel) {
|
|
|
|
|
writeDebug(msg, fields...)
|
|
|
|
@ -142,7 +142,7 @@ func Errorv(v any) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Errorw writes msg along with fields into error log.
|
|
|
|
|
// Errorw writes msg along with fields into the error log.
|
|
|
|
|
func Errorw(msg string, fields ...LogField) {
|
|
|
|
|
if shallLog(ErrorLevel) {
|
|
|
|
|
writeError(msg, fields...)
|
|
|
|
@ -208,7 +208,7 @@ func Infov(v any) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Infow writes msg along with fields into access log.
|
|
|
|
|
// Infow writes msg along with fields into the access log.
|
|
|
|
|
func Infow(msg string, fields ...LogField) {
|
|
|
|
|
if shallLog(InfoLevel) {
|
|
|
|
|
writeInfo(msg, fields...)
|
|
|
|
@ -254,11 +254,12 @@ func SetWriter(w Writer) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetUp sets up the logx. If already set up, just return nil.
|
|
|
|
|
// we allow SetUp to be called multiple times, because for example
|
|
|
|
|
// SetUp sets up the logx.
|
|
|
|
|
// If already set up, return nil.
|
|
|
|
|
// We allow SetUp to be called multiple times, because, for example,
|
|
|
|
|
// we need to allow different service frameworks to initialize logx respectively.
|
|
|
|
|
func SetUp(c LogConf) (err error) {
|
|
|
|
|
// Just ignore the subsequent SetUp calls.
|
|
|
|
|
// Ignore the later SetUp calls.
|
|
|
|
|
// Because multiple services in one process might call SetUp respectively.
|
|
|
|
|
// Need to wait for the first caller to complete the execution.
|
|
|
|
|
setupOnce.Do(func() {
|
|
|
|
@ -480,7 +481,7 @@ func writeDebug(val any, fields ...LogField) {
|
|
|
|
|
getWriter().Debug(val, addCaller(fields...)...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// writeError writes v into error log.
|
|
|
|
|
// writeError writes v into the error log.
|
|
|
|
|
// Not checking shallLog here is for performance consideration.
|
|
|
|
|
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
|
|
|
|
|
// The caller should check shallLog before calling this function.
|
|
|
|
@ -520,7 +521,7 @@ func writeStack(msg string) {
|
|
|
|
|
getWriter().Stack(fmt.Sprintf("%s\n%s", msg, string(debug.Stack())))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// writeStat writes v into stat log.
|
|
|
|
|
// writeStat writes v into the stat log.
|
|
|
|
|
// Not checking shallLog here is for performance consideration.
|
|
|
|
|
// If we check shallLog here, the fmt.Sprint might be called even if the log level is not enabled.
|
|
|
|
|
// The caller should check shallLog before calling this function.
|
|
|
|
|