use anchore/go-logger interface

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2022-02-05 12:04:36 -05:00
parent e474b2f23c
commit 69692ad901
10 changed files with 48 additions and 217 deletions
+6 -7
View File
@@ -7,12 +7,12 @@ import (
"bytes"
"context"
"fmt"
"github.com/anchore/go-logger"
"io"
"os"
"sync"
"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/internal/logger"
syftEvent "github.com/anchore/syft/syft/event"
"github.com/anchore/syft/ui"
"github.com/wagoodman/go-partybus"
@@ -59,9 +59,8 @@ func (h *ephemeralTerminalUI) Setup(unsubscribe func() error) error {
// prep the logger to not clobber the screen from now on (logrus only)
h.logBuffer = bytes.NewBufferString("")
logWrapper, ok := log.Log.(*logger.LogrusLogger)
if ok {
logWrapper.Logger.SetOutput(h.logBuffer)
if rootLogger, ok := log.Log.(logger.Controller); ok {
rootLogger.SetOutput(h.logBuffer)
}
return h.openScreen()
@@ -129,10 +128,10 @@ func (h *ephemeralTerminalUI) closeScreen(force bool) {
func (h *ephemeralTerminalUI) flushLog() {
// flush any errors to the screen before the report
logWrapper, ok := log.Log.(*logger.LogrusLogger)
rootLogger, ok := log.Log.(logger.Controller)
if ok {
fmt.Fprint(logWrapper.Output, h.logBuffer.String())
logWrapper.Logger.SetOutput(h.uiOutput)
fmt.Fprint(rootLogger.GetOutput(), h.logBuffer.String())
rootLogger.SetOutput(h.uiOutput)
} else {
fmt.Fprint(h.uiOutput, h.logBuffer.String())
}