Ai
1 Star 0 Fork 0

pheker/learn-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
LogUtil.go 617 Bytes
一键复制 编辑 原始数据 按行查看 历史
pheker 提交于 2021-12-07 00:36 +08:00 . add bat,FileUtil
package utils
import (
"log"
"os"
)
// SetLogPath 设置日志路径
func SetLogPath(logPath string) {
SetLogPathAndPrefix(logPath, "")
}
// SetLogPathAndPrefix 设置日志路径与前缀
func SetLogPathAndPrefix(logPath string, prefix string) *os.File {
logFile, err := os.OpenFile(logPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
//defer logFile.Close()
if err != nil {
panic(err)
}
// 将文件设置为log输出的文件
log.SetOutput(logFile)
log.SetPrefix(prefix)
log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC)
log.Printf("logpath has been set to %s\n", logPath)
return logFile
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pheker/learn-go.git
git@gitee.com:pheker/learn-go.git
pheker
learn-go
learn-go
v1.0.4

搜索帮助