Exemple #1
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
}
Exemple #2
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(""),
	)
}
Exemple #3
0
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
}
Exemple #4
0
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
}