func main() { baseDir, err := os.Getwd() quitIfErr(err) skipDirFlag := flag.String("skip", "trash", "Comma-separated list of directories to skip") buildOnlyFlag := flag.Bool("buildOnly", false, "Do \"go build\" instead of \"go test\"") shortFlag := flag.Bool("short", false, `Run "go test" with "short" flag`) colorFlag := flag.Bool("c", true, "Use colorized log output, colored by severity") verboseFlag := flag.Bool("v", false, `Run "go test" with -v, also be more verbose elsewhere`) veryVerbose := flag.Bool("vv", false, `Very Verbose, comine stdout AND stderr to display`) raceFlag := flag.Bool("race", false, `Run "go test" with "race" flag`) flag.Parse() gou.SetLogger(log.New(os.Stderr, "", 0), "debug") if *colorFlag { gou.SetColorIfTerminal() } skipDirNames := strings.Split(*skipDirFlag, ",") skipDirStats := make([]os.FileInfo, 0) for _, skipDirName := range skipDirNames { if skipDirName == "" { continue } stat, err := os.Stat(skipDirName) if skipDirName == "trash" && err != nil { continue } if err != nil { gou.Errorf("Couldn't stat directory to skip %s: %s\n", skipDirName, err) } skipDirStats = append(skipDirStats, stat) } conf := NewConf(skipDirStats, *buildOnlyFlag, *shortFlag, *raceFlag, *verboseFlag, *veryVerbose) failedDirs := RunTestsRecursively(baseDir, baseDir, conf) if len(failedDirs) > 0 { gou.Error("\nFailed directories:") for _, dir := range failedDirs { gou.Errorf(" %s", dir) } os.Exit(1) } else { gou.Info("\nall tests/builds succeeded") } }
func main() { flag.Parse() u.SetupLogging("debug") u.SetColorIfTerminal() deprlib.BASE_BRANCH = baseBranch yamlBytes, err := ioutil.ReadFile(config) //Debug(string(yamlBytes)) quitIfErr(err) goroot := runtime.GOROOT() goCmdPath = goroot + "/bin/go" deprlib.GoCmdPath = goCmdPath var d deprlib.Dependencies err = yaml.Unmarshal(yamlBytes, &d) err = d.Run(allowNonClean) quitIfErr(err) }
func main() { flag.Parse() u.SetupLogging(logLevel) u.SetColorIfTerminal() // this doesn't work if reading stdin if colorize { u.SetColorOutput() } done := make(chan bool) esHostName = cleanEsHost(esHostName) // if we have note specified tail files, then assume stdin if len(flag.Args()) == 0 && source == "tail" { source = "stdin" } u.Debugf("LOGES: filters=%s es=%s argct=:%d source=%v ll=%s args=%v", filters, esHostName, len(flag.Args()), source, logLevel, flag.Args()) // Setup output first, to ensure its ready when Source starts // TODO: suuport multiple outputs? switch output { case "elasticsearch": // update the Logstash date for the index occasionally go loges.UpdateLogstashIndex() // start an elasticsearch bulk worker, for sending to elasticsearch go loges.ToElasticSearch(msgChan, "golog", esHostName, ttl, exitIfNoMsgsDur, metricsToEs) case "stdout": u.Debug("setting output to stdout ", colorize) go loges.ToStdout(msgChan, colorize) default: Usage() os.Exit(1) } // TODO: implement metrics out for _, metOut := range strings.Split(metricsOut, ",") { switch metOut { case "influxdb": // todo case "graphite": u.Infof("Registering Graphite Transform: host=%s prefix=%s", graphiteHost, graphitePrefix) loges.TransformRegister(loges.GraphiteTransform(logType, graphiteHost, graphitePrefix, true)) } } // now set up the transforms/filters for _, filter := range strings.Split(filters, ",") { switch filter { case "stdfiles": loges.TransformRegister(loges.FileFormatter(logType, nil)) case "fluentd": loges.TransformRegister(loges.FluentdFormatter(logType, nil)) case "kafka": // TODO, finish conversion to sarama //loges.TransformRegister(kafka.KafkaFormatter) } } for _, sourceInput := range strings.Split(source, ",") { u.Warnf("source = %v", sourceInput) switch sourceInput { case "tail": for _, filename := range flag.Args() { tailDone := make(chan bool) go loges.TailFile(filename, tail.Config{Follow: true, ReOpen: true}, tailDone, msgChan) } case "http": go loges.HttpRun(httpPort, msgChan) //case "kafka": // go kafka.RunKafkaConsumer(msgChan, partitionstr, topic, kafkaHost, offset, maxMsgCt, maxSize) case "stdin": go loges.StdinPruducer(msgChan) default: u.Error(sourceInput) println("No input set, required") Usage() os.Exit(1) } } u.Warn("end of main startup, until done") <-done }