示例#1
0
func TestNull(t *testing.T) {
	log.SetNull()
	log.SetLevel(-1000)
	if log.IsTrace() {
		t.Error("There should be no trace")
	}
	if log.IsDebug() {
		t.Error("There should be no debug")
	}
	if log.IsInfo() {
		t.Error("There should be no info")
	}
	if log.IsWarn() {
		t.Error("There should be no warn")
	}
	var args []interface{}
	args = append(args, "key1", 1, "key2", 3.14152)

	log.Trace("Hello World", args...)
	log.Debug("Hello World", args...)
	log.Info("Hello World", args...)
	log.Warn("Hello World", args...)
	log.Error("Hello World", args...)
	log.Log(1, "Hello World", args)
}
示例#2
0
// NewConfiguration creates a new validated SectionSlice with a three level configuration.
// Panics if a path is redundant.
func NewConfiguration(sections ...*Section) SectionSlice {
	ss := SectionSlice(sections)
	if err := ss.Validate(); err != nil {
		if log.IsWarn() {
			log.Warn("config.NewConfiguration.Validate", "err", err)
		}
		panic(err)
	}
	return ss
}
示例#3
0
// NewConfigurationMerge creates a new validated SectionSlice with a three level configuration.
// Before validation, slices are all merged together. Panics if a path is redundant.
// Only use this function if your package configuration really has duplicated entries.
func NewConfigurationMerge(sections ...*Section) SectionSlice {
	var ss SectionSlice
	ss.Merge(sections...)
	if err := ss.Validate(); err != nil {
		if log.IsWarn() {
			log.Warn("config.NewConfigurationMerge.Validate", "err", err)
		}
		panic(err)
	}
	return ss
}