forked from authelia/authelia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(logging): implement common interfaces (authelia#3994)
This implements and leverages some common library logging interfaces.
- Loading branch information
1 parent
4e88698
commit d7fd9ca
Showing
5 changed files
with
52 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package logging | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// PrintfLogger is a logger that implements a common Printf logger. | ||
type PrintfLogger struct { | ||
level logrus.Level | ||
logrus *logrus.Logger | ||
} | ||
|
||
// Printf is the implementation of the interface. | ||
func (l *PrintfLogger) Printf(format string, args ...interface{}) { | ||
l.logrus.Logf(l.level, format, args...) | ||
} | ||
|
||
// CtxPrintfLogger is a logger that implements a common Printf logger with a ctx. | ||
type CtxPrintfLogger struct { | ||
level logrus.Level | ||
logrus *logrus.Logger | ||
} | ||
|
||
// Printf is the implementation of the interface. | ||
func (l *CtxPrintfLogger) Printf(_ context.Context, format string, args ...interface{}) { | ||
l.logrus.Logf(l.level, format, args...) | ||
} |
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