54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package util
|
|
|
|
import (
|
|
"context"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/os/gcache"
|
|
)
|
|
|
|
var RedisCache = func() *gcache.Cache {
|
|
cache := gcache.New()
|
|
cache.SetAdapter(gcache.NewAdapterRedis(g.Redis()))
|
|
return cache
|
|
}()
|
|
|
|
// Info 全局Info日志
|
|
func Info(ctx context.Context, args ...interface{}) {
|
|
g.Log().Info(ctx, args...)
|
|
}
|
|
|
|
// Infof 全局Info格式化日志
|
|
func Infof(ctx context.Context, format string, args ...interface{}) {
|
|
g.Log().Infof(ctx, format, args...)
|
|
}
|
|
|
|
// Debug 全局Debug日志
|
|
func Debug(ctx context.Context, args ...interface{}) {
|
|
g.Log().Debug(ctx, args...)
|
|
}
|
|
|
|
// Debugf 全局Debug格式化日志
|
|
func Debugf(ctx context.Context, format string, args ...interface{}) {
|
|
g.Log().Debugf(ctx, format, args...)
|
|
}
|
|
|
|
// Error 全局Error日志
|
|
func Error(ctx context.Context, args ...interface{}) {
|
|
g.Log().Error(ctx, args...)
|
|
}
|
|
|
|
// Errorf 全局Error格式化日志
|
|
func Errorf(ctx context.Context, format string, args ...interface{}) {
|
|
g.Log().Errorf(ctx, format, args...)
|
|
}
|
|
|
|
// Warn 全局Warn日志
|
|
func Warn(ctx context.Context, args ...interface{}) {
|
|
g.Log().Warning(ctx, args...)
|
|
}
|
|
|
|
// Warnf 全局Warn格式化日志
|
|
func Warnf(ctx context.Context, format string, args ...interface{}) {
|
|
g.Log().Warningf(ctx, format, args...)
|
|
}
|