Fix #78: log all warnings

1. Log all warnings, don't hide none of them
2. Write fatal messages (stop analysis) with error log level
3. Remove ugly timestamp counter from logrus output
4. Print nested module prefix in log
5. Make logger abstraction: no global logging anymore
6. Refactor config reading to config.FileReader struct to avoid passing
logger into every function
7. Replace exit codes hardcoding with constants in exitcodes package
8. Fail test if any warning was logged
9. Fix calculation of relative path if we analyze parent dir ../
10. Move Runner initialization from Executor to NewRunner func
11. Log every AST parsing error
12. Properly print used config file path in verbose mode
13. Print package files if only 1 package is analyzedin verbose mode,
  print not compiling packages in verbose mode
14. Forbid usage of github.com/sirupsen/logrus by DepGuard linter
15. Add default ignore pattern to folint: "comment on exported const"
This commit is contained in:
Denis Isaev 2018-06-13 22:37:48 +03:00 committed by Isaev Denis
parent 219a5479c8
commit 9181ca7175
40 changed files with 694 additions and 432 deletions

View file

@ -7,22 +7,24 @@ import (
"sync"
"time"
"github.com/sirupsen/logrus"
"github.com/golangci/golangci-lint/pkg/logutils"
)
type Stopwatch struct {
name string
startedAt time.Time
stages map[string]time.Duration
log logutils.Log
sync.Mutex
}
func NewStopwatch(name string) *Stopwatch {
func NewStopwatch(name string, log logutils.Log) *Stopwatch {
return &Stopwatch{
name: name,
startedAt: time.Now(),
stages: map[string]time.Duration{},
log: log,
}
}
@ -53,11 +55,11 @@ func (s *Stopwatch) sprintStages() string {
func (s *Stopwatch) Print() {
p := fmt.Sprintf("%s took %s", s.name, time.Since(s.startedAt))
if len(s.stages) == 0 {
logrus.Info(p)
s.log.Infof("%s", p)
return
}
logrus.Infof("%s with %s", p, s.sprintStages())
s.log.Infof("%s with %s", p, s.sprintStages())
}
func (s *Stopwatch) PrintStages() {
@ -65,7 +67,7 @@ func (s *Stopwatch) PrintStages() {
for _, s := range s.stages {
stagesDuration += s
}
logrus.Infof("%s took %s with %s", s.name, stagesDuration, s.sprintStages())
s.log.Infof("%s took %s with %s", s.name, stagesDuration, s.sprintStages())
}
func (s *Stopwatch) TrackStage(name string, f func()) {

View file

@ -4,9 +4,9 @@ import (
"fmt"
"time"
"github.com/sirupsen/logrus"
"github.com/golangci/golangci-lint/pkg/logutils"
)
func Track(from time.Time, format string, args ...interface{}) {
logrus.Infof("%s took %s", fmt.Sprintf(format, args...), time.Since(from))
func Track(from time.Time, log logutils.Log, format string, args ...interface{}) {
log.Infof("%s took %s", fmt.Sprintf(format, args...), time.Since(from))
}