1、logtools包代码
package logtools
import (
"encoding/json"
"fmt"
log "github.com/cihub/seelog"
"io/ioutil"
)
type LogCfg struct {
Levels string `json:"levels"` // 日志等级
FmtId string `json:"fmt_id"` // 日志分类id
RollType string `json:"roll_type"` // 打包类型,data: 按日期打包,size: 按大小打包
FileName string `json:"file_name"` // 文件名
RollTypeParam string `json:"roll_type_param"` // 打包参数,日期格式/数据大小
RollTypeMaxRolls string `json:"roll_type_max_rolls"` // 最大上线,日期:30天
}
type LocalLogInterface log.LoggerInterface
func RollingFile(cfg *LogCfg) (LocalLogInterface, error) {
logConfigTemp := `
<seelog type="sync" levels="%s" >
<outputs formatid="%s">
<rollingfile ty