升级依赖库
This commit is contained in:
@ -8,9 +8,9 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/logger"
|
||||
"git.zhangdeman.cn/zhangdeman/websocket/storage"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"gopkg.in/olahol/melody.v1"
|
||||
@ -41,7 +41,7 @@ const (
|
||||
// DefaultLogLevel 默认的日志级别
|
||||
DefaultLogLevel = zapcore.DebugLevel
|
||||
// DefaultLogSplitInterval 默认的日志切割时间
|
||||
DefaultLogSplitInterval = logger.TimeIntervalTypeHour
|
||||
DefaultLogSplitInterval = consts.LogSplitHour
|
||||
// DefaultStoreConnection 默认存储连接
|
||||
DefaultStoreConnection = true
|
||||
// DefaultEnablePprof 默认关闭pprof
|
||||
@ -64,18 +64,18 @@ const (
|
||||
//
|
||||
// Date : 7:02 下午 2021/4/17
|
||||
type WSServerConfig struct {
|
||||
Mode string // 运行模式
|
||||
LogEnable bool // 开启日志
|
||||
LogConsole bool // 开启控制台日志输出
|
||||
LogPath string // 日志路径
|
||||
LogFile string // 日志文件名
|
||||
LogLevel zapcore.Level // 日志等级
|
||||
LogSplitInterval logger.TimeIntervalType // 日至切割的时间间隔
|
||||
StoreConnection bool // 存储连接
|
||||
ConnectionManager storage.IConnection // 连接管理实例
|
||||
EnablePprof bool // 开启pprof, 默认关闭
|
||||
PprofPort int // pprof监听的端口
|
||||
melody.Config // 长连接配置
|
||||
Mode string // 运行模式
|
||||
LogEnable bool // 开启日志
|
||||
LogConsole bool // 开启控制台日志输出
|
||||
LogPath string // 日志路径
|
||||
LogFile string // 日志文件名
|
||||
LogLevel zapcore.Level // 日志等级
|
||||
LogSplitInterval string // 日至切割的时间间隔
|
||||
StoreConnection bool // 存储连接
|
||||
ConnectionManager storage.IConnection // 连接管理实例
|
||||
EnablePprof bool // 开启pprof, 默认关闭
|
||||
PprofPort int // pprof监听的端口
|
||||
melody.Config // 长连接配置
|
||||
}
|
||||
|
||||
// SetWSServerConfig 设置WS-Server的配置
|
||||
@ -90,16 +90,8 @@ type SetWSServerConfig func(wsc *WSServerConfig)
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 7:25 下午 2021/4/17
|
||||
func SetWSServerLogEnable(logPath string, logFile string, logLevel zapcore.Level, splitInterval logger.TimeIntervalType) SetWSServerConfig {
|
||||
func SetWSServerLogEnable(logPath string, logFile string, logLevel zapcore.Level, splitInterval string) SetWSServerConfig {
|
||||
return func(wsc *WSServerConfig) {
|
||||
if splitInterval != logger.TimeIntervalTypeMinute &&
|
||||
splitInterval != logger.TimeIntervalTypeHour &&
|
||||
splitInterval != logger.TimeIntervalTypeDay &&
|
||||
splitInterval != logger.TimeIntervalTypeMonth &&
|
||||
splitInterval != logger.TimeIntervalTypeYear {
|
||||
// 传入非法值,默认按小时切割日志
|
||||
splitInterval = DefaultLogSplitInterval
|
||||
}
|
||||
if len(logPath) == 0 {
|
||||
logPath = "./logs"
|
||||
}
|
||||
|
Reference in New Issue
Block a user