@@ -15,7 +15,6 @@ import (
1515
1616const (
1717 DebugFlag = "debugAddr"
18- InvalidLagerLogLevel = 99
1918)
2019
2120type 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