go-lib

module
v0.0.0-...-42829d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2021 License: Apache-2.0

README

go-lib

GitHub GoDoc FOSSA Status

Installation

go get -u github.com/baidu/go-lib

Documentation

Contributing

  • Please create an issue in issue list.
  • Following the golang coding standards.

License

The project is under the Apache 2.0 license. See the LICENSE file for details.

Directories

Path Synopsis
log
Usage: import "github.com/baidu/go-lib/log" // Two log files will be generated in ./log: // test.log, and test.wf.log(for log > warn) // The log will rotate, and there is support for backup count log.Init("test", "INFO", "./log", true, "midnight", 5) log.Logger.Warn("warn msg") log.Logger.Info("info msg") // it is required, to work around bug of log4go time.Sleep(100 * time.Millisecond)
Usage: import "github.com/baidu/go-lib/log" // Two log files will be generated in ./log: // test.log, and test.wf.log(for log > warn) // The log will rotate, and there is support for backup count log.Init("test", "INFO", "./log", true, "midnight", 5) log.Logger.Warn("warn msg") log.Logger.Info("info msg") // it is required, to work around bug of log4go time.Sleep(100 * time.Millisecond)
log4go
Package log4go provides level-based and highly configurable logging.
Package log4go provides level-based and highly configurable logging.
time
timefmt
Usage: import "icode.baidu.com/go-lib/time/timefmt" println(timefmt.CurrTimeGet()) // 2006-01-02 15:04:05
Usage: import "icode.baidu.com/go-lib/time/timefmt" println(timefmt.CurrTimeGet()) // 2006-01-02 15:04:05
web-monitor
metrics
Usage: import "github.com/baidu/go-lib/web-monitor/metrics" // define counter struct type type ServerState { ReqServed *Counter // field type must be *Counter or *Gauge or *State ConServed *Counter ConActive *Gauge } // create metrics var m Metrics var s ServerState m.Init(&s, "PROXY", 20) // counter operations s.ConActive.Inc(2) s.ConServed.Inc(1) s.ReqServed.Inc(1) s.ConActive.Dec(1) m.Counter("CounterName").Inc(1) m.Gauge("GaugeName").Inc(1) m.State("StateName").Set("StateValue") // get absoulute data for all metrics stateData := m.GetAll() // get diff data for all counters(gauge don't have diff data) stateDiff := m.GetDiff()
Usage: import "github.com/baidu/go-lib/web-monitor/metrics" // define counter struct type type ServerState { ReqServed *Counter // field type must be *Counter or *Gauge or *State ConServed *Counter ConActive *Gauge } // create metrics var m Metrics var s ServerState m.Init(&s, "PROXY", 20) // counter operations s.ConActive.Inc(2) s.ConServed.Inc(1) s.ReqServed.Inc(1) s.ConActive.Dec(1) m.Counter("CounterName").Inc(1) m.Gauge("GaugeName").Inc(1) m.State("StateName").Set("StateValue") // get absoulute data for all metrics stateData := m.GetAll() // get diff data for all counters(gauge don't have diff data) stateDiff := m.GetDiff()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL