// Test logging from level warning and above. func TestWarningAndAbove(t *testing.T) { logger.SetLevel(logger.LevelWarning) logger.Debugf("Debug.") logger.Infof("Info.") logger.Warningf("Warning.") logger.Errorf("Error.") logger.Criticalf("Critical.") }
// Test log at all levels. func TestAllLevels(t *testing.T) { logger.SetLevel(logger.LevelDebug) logger.Debugf("Debug.") logger.Infof("Info.") logger.Warningf("Warning.") logger.Errorf("Error.") logger.Criticalf("Critical.") }
// Test logging with the go logger. func TestGoLogger(t *testing.T) { log.SetOutput(os.Stdout) logger.SetLevel(logger.LevelDebug) logger.SetLogger(logger.NewGoLogger()) logger.Debugf("Debug.") logger.Infof("Info.") logger.Warningf("Warning.") logger.Errorf("Error.") logger.Criticalf("Critical.") }
// Test logging with an own logger. func TestOwnLogger(t *testing.T) { assert := asserts.NewTestingAssertion(t, true) ownLogger := &testLogger{[]string{}} logger.SetLevel(logger.LevelDebug) logger.SetLogger(ownLogger) logger.Debugf("Debug.") logger.Infof("Info.") logger.Warningf("Warning.") logger.Errorf("Error.") logger.Criticalf("Critical.") assert.Length(ownLogger.logs, 5, "Everything logged.") }
// Test logging with the syslogger. func TestSysLogger(t *testing.T) { assert := asserts.NewTestingAssertion(t, true) logger.SetLevel(logger.LevelDebug) sl, err := logger.NewSysLogger("GOAS") assert.Nil(err) logger.SetLogger(sl) logger.Debugf("Debug.") logger.Infof("Info.") logger.Warningf("Warning.") logger.Errorf("Error.") logger.Criticalf("Critical.") }
// Test debugging. func TestDebug(t *testing.T) { logger.Debugf("Hello, I'm debugging %v!", "here") logger.SetLevel(logger.LevelError) logger.Debugf("Should not be shown!") }