From c396a3c5364bbedd75c06b0bc49054236c91b110 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 23 Apr 2020 15:13:35 -0400 Subject: [PATCH] Log out-of-order tags if -loglevel=debug. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- import.go | 9 ++++++++- tilelib.go | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/import.go b/import.go index d50843d079..36558ca8d6 100644 --- a/import.go +++ b/import.go @@ -52,6 +52,7 @@ func (cmd *importer) RunCommand(prog string, args []string, stdin io.Reader, std flags.BoolVar(&cmd.skipOOO, "skip-ooo", false, "skip out-of-order tags") priority := flags.Int("priority", 500, "container request priority") pprof := flags.String("pprof", "", "serve Go profile data at http://`[addr]:port`") + loglevel := flags.String("loglevel", "info", "logging threshold (trace, debug, info, warn, error, fatal, or panic)") err = flags.Parse(args) if err == flag.ErrHelp { err = nil @@ -72,6 +73,12 @@ func (cmd *importer) RunCommand(prog string, args []string, stdin io.Reader, std }() } + lvl, err := log.ParseLevel(*loglevel) + if err != nil { + return 2 + } + log.SetLevel(lvl) + if !cmd.runLocal { runner := arvadosContainerRunner{ Name: "lightning import", @@ -101,7 +108,7 @@ func (cmd *importer) RunCommand(prog string, args []string, stdin io.Reader, std err = errors.New("cannot specify output file in container mode: not implemented") return 1 } - runner.Args = append([]string{"import", "-local=true", fmt.Sprintf("-skip-ooo=%v", cmd.skipOOO), "-tag-library", cmd.tagLibraryFile, "-ref", cmd.refFile, "-o", cmd.outputFile}, inputs...) + runner.Args = append([]string{"import", "-local=true", "-loglevel=" + *loglevel, fmt.Sprintf("-skip-ooo=%v", cmd.skipOOO), "-tag-library", cmd.tagLibraryFile, "-ref", cmd.refFile, "-o", cmd.outputFile}, inputs...) var output string output, err = runner.Run() if err != nil { diff --git a/tilelib.go b/tilelib.go index 339bc215e3..c2ea54e812 100644 --- a/tilelib.go +++ b/tilelib.go @@ -98,13 +98,16 @@ func (tilelib *tileLibrary) TileFasta(filelabel string, rdr io.Reader) (tileSeq, path = path[:0] last := foundtag{tagid: -1} for i, f := range found { + log.Tracef("%s %s found[%d] == %#v", filelabel, job.label, i, f) if tilelib.skipOOO { if f.tagid < last.tagid+1 { // e.g., last=B, this=A + log.Debugf("%s %s skipped out-of-order tag %d (found at %d) because it follows tag %d (found at %d)", filelabel, job.label, f.tagid, f.pos, last.tagid, last.pos) continue } if f.tagid > last.tagid+1 && i+1 < len(found) && found[i+1].tagid <= f.tagid { // e.g., last=A, this=C, next=B + log.Debugf("%s %s skipped out-of-order tag %d (found at %d) because it appears between tag %d (found at %d) and %d (found at %d)", filelabel, job.label, f.tagid, f.pos, last.tagid, last.pos, found[i+1].tagid, found[i+1].pos) continue } } -- 2.30.2