예제 #1
0
// Set module name
func (log *LogEssence) SetModuleName(name string) Log {
	var rec *r.Record
	if name != "" {
		rec = t.NewTrace().Trace(t.STEP_BACK + 1).GetRecord()
		log.moduleNames[rec.Package] = name
	}
	return log.Interface
}
예제 #2
0
func (log *LogEssence) leveled(level l.Level, args ...interface{}) *LogEssence {
	log.CustomMessage(
		m.NewMessage(
			t.NewTrace().
				Trace(t.STEP_BACK + 2).
				GetRecord().
				Resolver(log.ResolveNames),
		).Level(level).
			Write(args...),
	)
	return log
}
예제 #3
0
func TestCustomMessage(tst *testing.T) {
	singleton[default_LOGUUID].getEssence().InterceptStandardLog(false)
	singleton[default_LOGUUID].getEssence().backend = b.NewBackends()
	CustomMessage(m.NewMessage(
		t.NewTrace().
			Trace(t.STEP_BACK + 2).
			GetRecord().
			Resolver(singleton[default_LOGUUID].getEssence().ResolveNames),
	).Level(l.NOTICE).
		Write(""),
	)
}
예제 #4
0
파일: writer.go 프로젝트: webdeskltd/log
func (wr *Writer) write(buf string) (ln int, err error) {
	var msg *m.Message
	msg = m.NewMessage(
		t.NewTrace().
			Trace(t.STEP_BACK + 3).
			GetRecord().
			Resolver(wr.resolver),
	).
		Level(
			l.NewFromMesssage(buf, wr.level).Level,
		).
		Write(wr.cleanSpace(buf))
	if wr.backends != nil {
		wr.backends.Push(msg)
		ln, err = msg.GetResult()
	} else {
		// backend is not initialized, no place to send messages
	}
	return
}
예제 #5
0
파일: log_test.go 프로젝트: webdeskltd/log
func TestLogResolveNames(t *testing.T) {
	testing_mode_two = true
	singleton[default_LOGUUID].getEssence().InterceptStandardLog(false)
	singleton[default_LOGUUID].getEssence().backend = b.NewBackends()

	lg := NewLog().getEssence()
	lg.backend = b.NewBackends()
	lg.moduleNames["testing"] = "TestLogResolveNames"
	txt, _ := m.NewMessage(
		tr.NewTrace().
			Trace(tr.STEP_BACK).
			GetRecord().
			Resolver(lg.ResolveNames),
	).Level(l.NOTICE).
		Write("Test SetModuleName()").
		Prepare().
		Record.
		Format(`%{module} | %{package}`)
	if txt != "testing | TestLogResolveNames" {
		t.Errorf("Error in TestLogResolveNames()")
		return
	}
	testing_mode_two = false
}
예제 #6
0
// Remove module name
func (log *LogEssence) DelModuleName() Log {
	var rec *r.Record
	rec = t.NewTrace().Trace(t.STEP_BACK + 1).GetRecord()
	delete(log.moduleNames, rec.Package)
	return log.Interface
}