Git Product home page Git Product logo

glog's Introduction

glog

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

修改的地方:

  1. 增加每天切割日志文件的功能,程序运行时指定 --dailyRolling=true参数即可
  2. 将日志等级由原来的INFO WARN ERROR FATAL改为DEBUG INFO ERROR FATAL
  3. 增加日志输出等级设置,当日志信息等级低于输出等级时则不输出日志信息
  4. 将默认的刷新缓冲区时间由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 

glog's People

Contributors

dsymonds avatar michael-berlin avatar robpike avatar sdbaiguanghe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.