New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/sdbaiguanghe/glog

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sdbaiguanghe/glog

v0.0.0-20160701133742-ca74c069d4e1
Source
Go
Version published
Created
Source

glog

golang/glog的基础上做了一些修改。

修改的地方:

  • 增加每天切割日志文件的功能,程序运行时指定 --dailyRolling=true参数即可
  • 将日志等级由原来的INFO WARN ERROR FATAL改为DEBUG INFO ERROR FATAL
  • 增加日志输出等级设置,当日志信息等级低于输出等级时则不输出日志信息
  • 将默认的刷新缓冲区时间由20s改为5s

##使用示例

func main() {
    //初始化命令行参数
    flag.Parse()
    //退出时调用,确保日志写入文件中
    defer glog.Flush()
    
    //一般在测试环境下设置输出等级为DEBUG,线上环境设置为INFO
    glog.SetLevelString("DEBUG") 
    
    glog.Info("hello, glog")
    glog.Warning("warning glog")
    glog.Error("error glog")
    
    glog.Infof("info %d", 1)
    glog.Warningf("warning %d", 2)
    glog.Errorf("error %d", 3)
 }
 
//假设编译后的可执行程序名为demo,运行时指定log_dir参数将日志文件保存到特定的目录
// ./demo --log_dir=./log --dailyRolling=true 

FAQs

Package last updated on 01 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts