Start to use leveled log

This commit is contained in:
2022-02-24 12:14:52 +01:00
parent f18cc034bb
commit abcf02e488
43 changed files with 156 additions and 67 deletions

View File

@ -2,11 +2,12 @@ package obiiter
import (
"fmt"
"log"
"sync"
"sync/atomic"
"time"
log "github.com/sirupsen/logrus"
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
"github.com/tevino/abool/v2"
)
@ -413,7 +414,7 @@ func (iterator IBioSequenceBatch) Rebatch(size int, sizes ...int) IBioSequenceBa
func (iterator IBioSequenceBatch) Recycle() {
log.Println("Start recycling of Bioseq objects")
log.Debugln("Start recycling of Bioseq objects")
recycled := 0
for iterator.Next() {
// iterator.Get()
@ -424,7 +425,7 @@ func (iterator IBioSequenceBatch) Recycle() {
}
batch.Recycle()
}
log.Printf("End of the recycling of %d Bioseq objects", recycled)
log.Debugf("End of the recycling of %d Bioseq objects", recycled)
}
func (iterator IBioSequenceBatch) Count(recycle bool) (int, int, int) {
@ -432,7 +433,7 @@ func (iterator IBioSequenceBatch) Count(recycle bool) (int, int, int) {
reads := 0
nucleotides := 0
log.Println("Start counting of Bioseq objects")
log.Debugln("Start counting of Bioseq objects")
for iterator.Next() {
// iterator.Get()
batch := iterator.Get()
@ -447,7 +448,7 @@ func (iterator IBioSequenceBatch) Count(recycle bool) (int, int, int) {
}
batch.Recycle()
}
log.Printf("End of the counting of %d Bioseq objects", variants)
log.Debugf("End of the counting of %d Bioseq objects", variants)
return variants, reads, nucleotides
}

View File

@ -1,7 +1,7 @@
package obiiter
import (
"log"
log "github.com/sirupsen/logrus"
"sync"
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"

View File

@ -6,7 +6,7 @@ import (
"github.com/schollz/progressbar/v3"
)
func (iterator IBioSequenceBatch) Speed() IBioSequenceBatch {
func (iterator IBioSequenceBatch) Speed(message ...string) IBioSequenceBatch {
newIter := MakeIBioSequenceBatch()
newIter.Add(1)
@ -15,13 +15,25 @@ func (iterator IBioSequenceBatch) Speed() IBioSequenceBatch {
newIter.WaitAndClose()
}()
bar := progressbar.NewOptions(
-1,
pbopt := make([]progressbar.Option, 0, 5)
pbopt = append(pbopt,
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionSetWidth(15),
progressbar.OptionShowCount(),
progressbar.OptionShowIts(),
progressbar.OptionSetDescription("[Sequence Processing]"))
)
if len(message) > 0 {
pbopt = append(pbopt,
progressbar.OptionSetDescription(message[0]),
)
} else {
pbopt = append(pbopt,
progressbar.OptionSetDescription("[Sequence Processing]"),
)
}
bar := progressbar.NewOptions(-1, pbopt...)
go func() {
@ -38,11 +50,10 @@ func (iterator IBioSequenceBatch) Speed() IBioSequenceBatch {
return newIter
}
func SpeedPipe() Pipeable {
f := func(iterator IBioSequenceBatch) IBioSequenceBatch {
return iterator.Speed()
}
return f
}
}

View File

@ -1,7 +1,7 @@
package obiiter
import (
"log"
log "github.com/sirupsen/logrus"
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
)
@ -39,7 +39,7 @@ func (iterator IBioSequenceBatch) MakeIWorker(worker SeqWorker, sizes ...int) IB
go func() {
newIter.WaitAndClose()
log.Println("End of the batch workers")
log.Debugln("End of the batch workers")
}()
@ -54,7 +54,7 @@ func (iterator IBioSequenceBatch) MakeIWorker(worker SeqWorker, sizes ...int) IB
newIter.Done()
}
log.Println("Start of the batch workers")
log.Debugln("Start of the batch workers")
for i := 0; i < nworkers-1; i++ {
go f(iterator.Split())
}