Example #1
0
File: log.go Project: l-k-/origins
		} else {
			f, err := os.Create(file)

			if err != nil {
				fmt.Println(err)
				os.Exit(1)
			}

			defer f.Close()

			w = f
		}

		switch format {
		case "csv":
			fw = origins.NewCSVWriter(w)
		default:
			logrus.Fatal("unknown format", format)
		}

		var count int

		if viper.GetBool("log_merge") {
			count = mergeDomains(engine, fw, domains, since, asof)
		} else {
			count = concatDomains(engine, fw, domains, since, asof)
		}

		fmt.Fprintf(os.Stderr, "%d facts\n", count)
	},
}
Example #2
0
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		var (
			iterator origins.Iterator
			writer   origins.Writer
		)

		// Data written to the buffer are converted into facts, normalized, and
		// copied to the CSV writer.
		iterator = origins.NewCSVReader(stdout)

		// Facts are written to stdout.
		writer = origins.NewCSVWriter(os.Stdout)

		// Modify the fact before writing using the passed arguments.
		// TODO: there is a overlap with the transactor.
		writer = &modWriter{
			writer: writer,
			modifier: func(f *origins.Fact) {
				if f.Domain == "" {
					f.Domain = domain
				}

				f.Operation = operation

				if f.Time.IsZero() {
					f.Time = t
				}