-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pcr0tool): Add support of a logger
- Loading branch information
Showing
21 changed files
with
137 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package log | ||
|
||
import ( | ||
"github.com/facebookincubator/go-belt/tool/logger" | ||
fianoLog "github.com/linuxboot/fiano/pkg/log" | ||
) | ||
|
||
var _ fianoLog.Logger = FianoLogger{} | ||
|
||
// FianoLogger is an implementation of a fiano/pkg/log.Logger based | ||
// on go-belt's Logger. Fiano is pretty noisy on low-important problems, | ||
// so we enforce another logging level. | ||
type FianoLogger struct { | ||
Backend logger.Logger | ||
LogAsLevel logger.Level | ||
} | ||
|
||
// NewFianoLogger returns a new instance of FianoLogger. | ||
// | ||
// Argument "log" is the actual logger used to log, and all non-fatal the logs | ||
// are logged with the specified logging level "logAsLevel". | ||
func NewFianoLogger(log logger.Logger, logAsLevel logger.Level) *FianoLogger { | ||
return &FianoLogger{ | ||
Backend: log, | ||
LogAsLevel: logAsLevel, | ||
} | ||
} | ||
|
||
func (l FianoLogger) Warnf(format string, args ...interface{}) { | ||
if l.Backend == nil { | ||
return | ||
} | ||
l.Backend.Logf(l.LogAsLevel, "[warn] "+format, args...) | ||
} | ||
func (l FianoLogger) Errorf(format string, args ...interface{}) { | ||
if l.Backend == nil { | ||
return | ||
} | ||
l.Backend.Logf(l.LogAsLevel, "[error] "+format, args...) | ||
} | ||
func (l FianoLogger) Fatalf(format string, args ...interface{}) { | ||
if l.Backend == nil { | ||
logger.Default().Fatalf(format, args...) | ||
return | ||
} | ||
l.Backend.Fatalf(format, args...) | ||
} |
Oops, something went wrong.