Exemplo n.º 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
}
Exemplo n.º 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
}
Exemplo n.º 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(""),
	)
}
Exemplo n.º 4
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
}
Exemplo n.º 5
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
}
Exemplo n.º 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
}