2022-11-24 23:37:34 +08:00
|
|
|
// Package queue
|
|
|
|
// @Link https://github.com/bufanyun/hotgo
|
2023-02-23 17:53:04 +08:00
|
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
2022-11-24 23:37:34 +08:00
|
|
|
// @Author Ms <133814250@qq.com>
|
|
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
2022-03-22 09:49:17 +08:00
|
|
|
//
|
2022-02-25 17:11:17 +08:00
|
|
|
package queue
|
|
|
|
|
|
|
|
import (
|
2023-01-25 11:49:21 +08:00
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
2022-02-25 17:11:17 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type RocketMqLogger struct {
|
|
|
|
Flag string
|
|
|
|
LevelLog string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *RocketMqLogger) Debug(msg string, fields map[string]interface{}) {
|
|
|
|
if l.LevelLog == "close" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if msg == "" && len(fields) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if l.LevelLog == "debug" || l.LevelLog == "all" {
|
2023-01-25 11:49:21 +08:00
|
|
|
g.Log().Debug(ctx, msg)
|
2022-02-25 17:11:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *RocketMqLogger) Level(level string) {
|
2023-01-25 11:49:21 +08:00
|
|
|
g.Log().Info(ctx, level)
|
2022-02-25 17:11:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (l *RocketMqLogger) OutputPath(path string) (err error) {
|
2023-01-25 11:49:21 +08:00
|
|
|
g.Log().Info(ctx, path)
|
2022-02-25 17:11:17 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *RocketMqLogger) Info(msg string, fields map[string]interface{}) {
|
|
|
|
if l.LevelLog == "close" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if msg == "" && len(fields) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if l.LevelLog == "info" || l.LevelLog == "all" {
|
2023-01-25 11:49:21 +08:00
|
|
|
g.Log().Info(ctx, msg)
|
2022-02-25 17:11:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *RocketMqLogger) Warning(msg string, fields map[string]interface{}) {
|
|
|
|
if l.LevelLog == "close" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if msg == "" && len(fields) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if l.LevelLog == "warn" || l.LevelLog == "all" {
|
2023-01-25 11:49:21 +08:00
|
|
|
g.Log().Warning(ctx, msg)
|
2022-02-25 17:11:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *RocketMqLogger) Error(msg string, fields map[string]interface{}) {
|
|
|
|
if l.LevelLog == "close" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if msg == "" && len(fields) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if l.LevelLog == "error" || l.LevelLog == "all" {
|
2023-01-25 11:49:21 +08:00
|
|
|
g.Log().Error(ctx, msg)
|
2022-02-25 17:11:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *RocketMqLogger) Fatal(msg string, fields map[string]interface{}) {
|
|
|
|
if l.LevelLog == "close" {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if msg == "" && len(fields) == 0 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if l.LevelLog == "fatal" || l.LevelLog == "all" {
|
2023-01-25 11:49:21 +08:00
|
|
|
g.Log().Fatal(ctx, msg)
|
2022-02-25 17:11:17 +08:00
|
|
|
}
|
|
|
|
}
|