remove WithFields; add stereoscope logging

This commit is contained in:
Alex Goodman
2020-05-23 19:22:52 -04:00
parent 51c972ad33
commit 1b9effeb49
10 changed files with 49 additions and 69 deletions
+2 -10
View File
@@ -42,11 +42,7 @@ func (a *Analyzer) Analyze(contents map[file.Reference]string) ([]pkg.Package, e
content, ok := contents[reference]
if !ok {
// TODO: test case
log.WithFields(map[string]interface{}{
"path": reference.Path,
"id": reference.ID(),
"analyzer": a.Name(),
}).Errorf("analyzer file content missing")
log.Errorf("analyzer '%s' file content missing: %+v", a.Name(), reference)
continue
}
@@ -54,11 +50,7 @@ func (a *Analyzer) Analyze(contents map[file.Reference]string) ([]pkg.Package, e
entries, err := ParseEntries(strings.NewReader(content))
if err != nil {
// TODO: test case
log.WithFields(map[string]interface{}{
"path": reference.Path,
"id": reference.ID(),
"analyzer": a.Name(),
}).Errorf("analyzer failed to parse entries: %w", err)
log.Errorf("analyzer failed to parse entries (reference=%+v): %w", reference, err)
continue
}
-6
View File
@@ -8,9 +8,3 @@ import (
func SetLogger(logger logger.Logger) {
log.Log = logger
}
func SetLoggerWithTags(logger logger.Logger, tags map[string]interface{}) {
log.Log = logger.WithFields(map[string]interface{}{
"source": LibraryName,
})
}
-1
View File
@@ -6,5 +6,4 @@ type Logger interface {
Info(args ...interface{})
Debugf(format string, args ...interface{})
Debug(args ...interface{})
WithFields(map[string]interface{}) Logger
}
+2 -8
View File
@@ -90,11 +90,7 @@ func (pres *Presenter) Present(output io.Writer, img *stereoscopeImg.Image, cata
fileMetadata, err := img.FileCatalog.Get(src)
if err != nil {
// TODO: test case
log.WithFields(map[string]interface{}{
"path": src.Path,
"id": src.ID(),
"presenter": "json",
}).Errorf("could not get metadata from catalog")
log.Errorf("could not get metadata from catalog (presenter=json): %+v", src)
}
srcObj := source{
@@ -110,9 +106,7 @@ func (pres *Presenter) Present(output io.Writer, img *stereoscopeImg.Image, cata
bytes, err := json.Marshal(&doc)
if err != nil {
log.WithFields(map[string]interface{}{
"presenter": "json",
}).Errorf("failed to marshal json: %w", err)
log.Errorf("failed to marshal json (presenter=json): %w", err)
}
_, err = output.Write(bytes)