package sneklog import "net/http" // HTTP method-specific log levels. var ( HTTPGetLevel = NewInfoLogLevelWithColors("get", FgGreen, BgNone) HTTPHeadLevel = NewInfoLogLevelWithColors("head", FgCyan, BgNone) HTTPPostLevel = NewInfoLogLevelWithColors("post", FgBlue, BgNone) HTTPPutLevel = NewInfoLogLevelWithColors("put", FgYellow, BgNone) HTTPPatchLevel = NewInfoLogLevelWithColors("patch", FgMagenta, BgNone) HTTPDeleteLevel = NewInfoLogLevelWithColors("delete", FgRed, BgNone) ) // Additional HTTP method-specific log levels. var ( HTTPOptionsLevel = NewDebugLogLevelWithColors("options", FgWhite, BgNone) HTTPConnectLevel = NewDebugLogLevelWithColors("connect", FgCyan, BgNone) HTTPTraceLevel = NewDebugLogLevelWithColors("trace", FgWhite, BgNone) HTTPUnknownLevel = NewDebugLogLevelWithColors("http", FgWhite, BgNone) ) // LogLevelForMethod returns the predefined log level associated with an HTTP method. func LogLevelForMethod(method string) LogLevel { switch method { case http.MethodGet: return HTTPGetLevel case http.MethodHead: return HTTPHeadLevel case http.MethodPost: return HTTPPostLevel case http.MethodPut: return HTTPPutLevel case http.MethodPatch: return HTTPPatchLevel case http.MethodDelete: return HTTPDeleteLevel case http.MethodOptions: return HTTPOptionsLevel case http.MethodConnect: return HTTPConnectLevel case http.MethodTrace: return HTTPTraceLevel default: return HTTPUnknownLevel } }