Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 820a319

Browse files
authored
Add LogAuth classification for logging authentication (#615)
* Add LogAuth classification for logging authentication * improve doc comment
1 parent 243526f commit 820a319

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

logger/logger.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const (
5555

5656
// LogDebug tells a logger to log all LogDebug, LogInfo, LogWarning, LogError, LogPanic and LogFatal entries passed to it.
5757
LogDebug
58+
59+
// LogAuth is a special case of LogDebug, it tells a logger to also log the body of an authentication request and response.
60+
// NOTE: this can disclose sensitive information, use with care.
61+
LogAuth
5862
)
5963

6064
const (
@@ -65,6 +69,7 @@ const (
6569
logWarning = "WARNING"
6670
logInfo = "INFO"
6771
logDebug = "DEBUG"
72+
logAuth = "AUTH"
6873
logUnknown = "UNKNOWN"
6974
)
7075

@@ -83,6 +88,8 @@ func ParseLevel(s string) (lt LevelType, err error) {
8388
lt = LogInfo
8489
case logDebug:
8590
lt = LogDebug
91+
case logAuth:
92+
lt = LogAuth
8693
default:
8794
err = fmt.Errorf("bad log level '%s'", s)
8895
}
@@ -106,6 +113,8 @@ func (lt LevelType) String() string {
106113
return logInfo
107114
case LogDebug:
108115
return logDebug
116+
case LogAuth:
117+
return logAuth
109118
default:
110119
return logUnknown
111120
}

0 commit comments

Comments
 (0)