Documentation ¶
Overview ¶
Package log publish with async mode, allow kafka, file, terminal configuration.
// Import V8 Engine. import "github.com/fuyibing/log/v8"
Initialize.
func init(){ // Follow configurations are optional. All of follows can be // configured in `config/log.yaml`. Filled with default if not // configured. log.Config.Set( conf.SetTimeFormat("2006-01-02 15:04:05.999999"), conf.SetLevel(conf.Error), conf.SetPrefix("Prefix"), conf.SetServiceAddr("172.16.0.110"), conf.SetServicePort(8080), conf.SetServiceEnvironment("production"), conf.SetServiceName("myapp"), conf.SetServiceVersion("1.2.3"), ) // If adapter changed by code, You must call log.Client.Reset() // to apply it. log.Config.Set(conf.SetAdapter(adapters.AdapterKafka)) log.Client.Reset() }
// Main process.
func main(){ // Wait for a while // until all logs publish completed. // // If the Close method `log.Client.Close()` is not set, Some logs // end of the application may be lost. defer log.Client.Close() ... log.Debug("debug info") log.Infof("info message: adapter=%s, level=%v", conf.Adapter, conf.Level) ... }
Index ¶
- Variables
- func AddTrace(ctx context.Context, request *http.Request)
- func Debug(text string)
- func Debugf(text string, args ...interface{})
- func Debugfc(ctx context.Context, text string, args ...interface{})
- func Error(text string)
- func Errorf(text string, args ...interface{})
- func Errorfc(ctx context.Context, text string, args ...interface{})
- func Fatal(text string)
- func Fatalf(text string, args ...interface{})
- func Fatalfc(ctx context.Context, text string, args ...interface{})
- func Info(text string)
- func Infof(text string, args ...interface{})
- func Infofc(ctx context.Context, text string, args ...interface{})
- func NewChild(ctx context.Context) context.Context
- func NewChildInfo(ctx context.Context, text string, args ...interface{}) context.Context
- func NewContext() context.Context
- func NewContextInfo(text string, args ...interface{}) context.Context
- func NewRequest(request *http.Request) context.Context
- func NewRequestInfo(request *http.Request, text string, args ...interface{}) context.Context
- func Panic(text string)
- func Panicf(text string, args ...interface{})
- func Panicfc(ctx context.Context, text string, args ...interface{})
- func Warn(text string)
- func Warnf(text string, args ...interface{})
- func Warnfc(ctx context.Context, text string, args ...interface{})
- type Map
- func (p Map) Debugf(text string, args ...interface{})
- func (p Map) Debugfc(ctx context.Context, text string, args ...interface{})
- func (p Map) Errorf(text string, args ...interface{})
- func (p Map) Errorfc(ctx context.Context, text string, args ...interface{})
- func (p Map) Fatalf(text string, args ...interface{})
- func (p Map) Fatalfc(ctx context.Context, text string, args ...interface{})
- func (p Map) Infof(text string, args ...interface{})
- func (p Map) Infofc(ctx context.Context, text string, args ...interface{})
- func (p Map) Warnf(text string, args ...interface{})
- func (p Map) Warnfc(ctx context.Context, text string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Config conf.Configuration Client core.Client )
Functions ¶
func NewChildInfo ¶
NewChildInfo set info level log before return new trace context, child of parent.
func NewContextInfo ¶
NewContextInfo set info level log before return new root context.
func NewRequest ¶
NewRequest create context based on http request. Return root context if parent trace not specified.
func NewRequestInfo ¶
NewRequestInfo set info level log before return. Create context based on http request. Return root context if parent trace not specified.
Types ¶
Click to show internal directories.
Click to hide internal directories.