func TestWritingToUDP(t *testing.T) { port := 16661 udp.SetAddr(fmt.Sprintf(":%d", port)) hook, err := NewPapertrailHook("localhost", port, "test") if err != nil { t.Errorf("Unable to connect to local UDP server.") } log := logrus.New() log.Hooks.Add(hook) udp.ShouldReceive(t, "foo", func() { log.Info("foo") }) }
func TestLocalhostAddAndPrint(t *testing.T) { log := logrus.New() hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") if err != nil { t.Errorf("Unable to connect to local syslog.") } log.Hooks.Add(hook) for _, level := range hook.Levels() { if len(log.Hooks[level]) != 1 { t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level])) } } log.Info("Congratulations!") }
"flag" "fmt" "io" "io/ioutil" "os" "path" "github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/Sirupsen/logrus" "github.com/cloudfoundry-incubator/docker_app_lifecycle/Godeps/_workspace/src/github.com/docker/docker/pkg/archive" ) var ( flDebug = flag.Bool("D", false, "debugging output") flNewDir = flag.String("newdir", "", "") flOldDir = flag.String("olddir", "", "") log = logrus.New() ) func main() { flag.Usage = func() { fmt.Println("Produce a tar from comparing two directory paths. By default a demo tar is created of around 200 files (including hardlinks)") fmt.Printf("%s [OPTIONS]\n", os.Args[0]) flag.PrintDefaults() } flag.Parse() log.Out = os.Stderr if (len(os.Getenv("DEBUG")) > 0) || *flDebug { logrus.SetLevel(logrus.DebugLevel) } var newDir, oldDir string