Skip to content

Commit

Permalink
feat: 将日志模块初始化移动到 rikkabot 包中
Browse files Browse the repository at this point in the history
  • Loading branch information
Clov614 committed Jan 19, 2025
1 parent a86c35a commit 41747fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
11 changes: 0 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ import (
)

func main() {
// 日志模块设置
logConfig := logging.Config{
LogPath: "./log/rikka.log",
ProjectKey: "bot", // 项目唯一标识,默认为 "project"
ProjectName: "rikka-bot-wechat",
MaxLogSize: 10 * 1024 * 1024, // 10MB, 日志文件最大大小
MonitorInterval: 4 * time.Hour, // 日志文件大小监控间隔
EnableConsoleOutput: true,
EnableFileOutput: true,
}
logging.InitLogger(logConfig)

// todo 支持自动获取sdk.dll 自动完成注入
// 是否开启调试模式
Expand Down
14 changes: 12 additions & 2 deletions rikkabot/rikkabot.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
wcf "github.com/Clov614/wcf-rpc-sdk"
"github.com/google/uuid"
"sync"
"time"
)

type RikkaBot struct {
Expand Down Expand Up @@ -44,8 +45,17 @@ var (

func init() {
cfg := config.GetConfig()
// 启动日志检测模块
go logging.MonitorLogSize(int64(cfg.LogMaxSize) * 1024 * 1024)
// 日志模块设置
logConfig := logging.Config{
LogPath: "./log/rikka.log",
ProjectKey: "bot", // 项目唯一标识,默认为 "project"
ProjectName: "rikka-bot-wechat",
MaxLogSize: int64(cfg.LogMaxSize) * 1024 * 1024, // 10MB, 日志文件最大大小
MonitorInterval: 4 * time.Hour, // 日志文件大小监控间隔
EnableConsoleOutput: true,
EnableFileOutput: true,
}
logging.InitLogger(logConfig)

}

Expand Down

0 comments on commit 41747fd

Please sign in to comment.