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

30
pkg/logutils/log.go Normal file
View file

@ -0,0 +1,30 @@
package logutils
type Log interface {
Fatalf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Warnf(format string, args ...interface{})
Infof(format string, args ...interface{})
Child(name string) Log
SetLevel(level LogLevel)
}
type LogLevel int
const (
// debug message, write to debug logs only by logutils.Debug
LogLevelDebug LogLevel = 0
// information messages, don't write too much messages,
// only useful ones: they are shown when running with -v
LogLevelInfo LogLevel = 1
// hidden errors: non critical errors: work can be continued, no need to fail whole program;
// tests will crash if any warning occured.
LogLevelWarn LogLevel = 2
// only not hidden from user errors: whole program failing, usually
// error logging happens in 1-2 places: in the "main" function.
LogLevelError LogLevel = 3
)