1 Star 0 Fork 1

ttpc2008/BaiduPCS-Go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
log_colorable_prefix.go 537 Bytes
一键复制 编辑 原始数据 按行查看 历史
package pcsutil
import (
"fmt"
"github.com/fatih/color"
"github.com/iikira/BaiduPCS-Go/pcsutil/pcstime"
"log"
)
var (
// ErrorColor 设置输出错误的颜色
ErrorColor = color.New(color.FgRed).SprintFunc()
)
// 自定义log writer
type logWriter struct{}
func (logWriter) Write(bytes []byte) (int, error) {
return fmt.Fprint(color.Output, "["+pcstime.BeijingTimeOption("Refer")+"] "+string(bytes))
}
// SetLogPrefix 设置日志输出的时间前缀
func SetLogPrefix() {
log.SetFlags(0)
log.SetOutput(new(logWriter))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ttpc2008/BaiduPCS-Go.git
git@gitee.com:ttpc2008/BaiduPCS-Go.git
ttpc2008
BaiduPCS-Go
BaiduPCS-Go
v3.5.4

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385