예제 #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.")
}
예제 #2
0
파일: kxps.go 프로젝트: ossrs/go-oryx-lib
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())
}
예제 #3
0
파일: kxps.go 프로젝트: ossrs/go-oryx-lib
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
}