Exemplo n.º 1
0
func ExampleLogger_ToConsole() {
	// Simply log to console.
	ol.Info.Println(nil, "The log text.")
	ol.Trace.Println(nil, "The log text.")
	ol.Warn.Println(nil, "The log text.")
	ol.Error.Println(nil, "The log text.")

	// Use short aliases.
	ol.I(nil, "The log text.")
	ol.T(nil, "The log text.")
	ol.W(nil, "The log text.")
	ol.E(nil, "The log text.")
}
Exemplo n.º 2
0
func (v *kxps) sample() (err error) {
	ctx := v.ctx

	defer func() {
		if r := recover(); r != nil {
			ol.W(ctx, "recover kxps from", r)
		}
	}()

	v.lock.Lock()
	defer v.lock.Unlock()

	if v.closed {
		return kxpsClosed
	}

	return v.doSample(time.Now())
}
Exemplo n.º 3
0
func (v *kxps) Start() (err error) {
	ctx := v.ctx

	go func() {
		for {
			if err := v.sample(); err != nil {
				if err == kxpsClosed {
					return
				}
				ol.W(ctx, "kxps ignore sample failed, err is", err)
			}
			time.Sleep(time.Duration(10) * time.Second)
		}
	}()

	v.started = true

	return
}