Skip to content

Commit d29dd51

Browse files
navinms711ameowlia
authored andcommitted
removed emojis and some excess comments
1 parent eca58cc commit d29dd51

File tree

2 files changed

+8
-29
lines changed

2 files changed

+8
-29
lines changed

adapter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ func normalizeLogLevel(input string) string {
4747
// It also normalizes the various forms of the same log level type. For ex: 0, d, debug are all same.
4848
func validateAndNormalize(w http.ResponseWriter, r *http.Request, level []byte) (string, error) {
4949
if r.Method != http.MethodPost {
50-
return "", errors.New("method not allowed, use POST")
50+
return "", errors.New("method not allowed, use POST")
5151
}
5252

5353
if r.TLS != nil {
54-
return "", errors.New("invalid scheme, https is not allowed")
54+
return "", errors.New("invalid scheme, https is not allowed")
5555
}
5656

5757
if len(level) == 0 {
58-
return "", errors.New("log level cannot be empty")
58+
return "", errors.New("log level cannot be empty")
5959
}
6060

6161
input := strings.TrimSpace(string(level))
6262
normalized := normalizeLogLevel(input)
6363
if normalized == "" {
64-
return "", errors.New("invalid log level: " + string(level))
64+
return "", errors.New("invalid log level: " + string(level))
6565
}
6666

6767
return normalized, nil

server.go

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
const (
1717
DebugFlag = "debugAddr"
18-
InvalidLagerLogLevel = 99
1918
)
2019

2120
type DebugServerConfig struct {
@@ -73,26 +72,6 @@ func Handler(zapCtrl zapLogLevelController) http.Handler {
7372
mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
7473
mux.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
7574
mux.Handle("/log-level", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
76-
// http://<>:<>/log-level -d {0, debug, DEBUG, d}
77-
// calls zapCtrl.SetMinLevel(lagerLogLevel) -> 0
78-
// calls grlog.SetLoggingLevel(zapLevel.String()) -> "debug"
79-
// calls conf.level.SetLevel(zapcore.DebugLevel)
80-
// http://<>:<>/log-level -d {1, info, INFO, I}
81-
// calls zapCtrl.SetMinLevel(lagerLogLevel) -> 1
82-
// calls grlog.SetLoggingLevel(zapLevel.String()) -> "info"
83-
// calls conf.level.SetLevel(zapcore.InfoLevel)
84-
// http://<>:<>/log-level -d {2, warn, WARN, w}
85-
// calls zapCtrl.SetMinLevel(lager.LogLevel(InvalidLagerLogLevel)) -> 99
86-
// calls conf.level.SetLevel(zapcore.WarnLevel)
87-
// http://<>:<>/log-level -d {3, error, ERROR, e}
88-
// calls zapCtrl.SetMinLevel(lagerLogLevel) -> 2
89-
// calls grlog.SetLoggingLevel(zapLevel.String()) -> "error"
90-
// calls conf.level.SetLevel(zapcore.ErrorLevel)
91-
// http://<>:<>/log-level -d {4, fatal, FATAL, f}
92-
// calls zapCtrl.SetMinLevel(lagerLogLevel) -> 3
93-
// calls grlog.SetLoggingLevel(zapLevel.String()) -> "fatal"
94-
// calls conf.level.SetLevel(zapcore.FatalLevel)
95-
9675
// Read the log level from the request body.
9776
level, err := io.ReadAll(r.Body)
9877
if err != nil {
@@ -109,10 +88,10 @@ func Handler(zapCtrl zapLogLevelController) http.Handler {
10988
if normalizedLevel == "warn" {
11089
// Note that zapcore.WarnLevel is not directly supported by lager.
11190
// And lager does not have a separate WARN level, it uses INFO for warnings.
112-
// So to set the minimum level to "warn" we send an Invalid log level,
91+
// So to set the minimum level to "warn" we send an Invalid log level of 99,
11392
// which hits the default case in the SetMinLevel method.
11493
// This is a workaround to ensure that the log level is set correctly.
115-
zapCtrl.SetMinLevel(lager.LogLevel(InvalidLagerLogLevel))
94+
zapCtrl.SetMinLevel(lager.LogLevel(99))
11695
} else {
11796
lagerLogLevel, err := lager.LogLevelFromString(normalizedLevel)
11897
if err != nil {
@@ -124,9 +103,9 @@ func Handler(zapCtrl zapLogLevelController) http.Handler {
124103
// Respond with a success message.
125104
w.WriteHeader(http.StatusOK)
126105
w.Header().Set("Content-Type", "text/plain")
127-
w.Write([]byte("/log-level was invoked with Level: " + normalizedLevel + "\n"))
106+
w.Write([]byte("/log-level was invoked with Level: " + normalizedLevel + "\n"))
128107
if normalizedLevel == "fatal" {
129-
w.Write([]byte("ℹ️ Note: Fatal logs are reported as error logs in the Gorouter logs.\n"))
108+
w.Write([]byte("Note: Fatal logs are reported as error logs in the Gorouter logs.\n"))
130109
}
131110
}))
132111
mux.Handle("/block-profile-rate", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)