-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VAULT-9427: Add read support to sys/loggers
endpoints
#17979
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit. Otherwise, looks good to me!
err = b.Core.SetLogLevelByName(nameRaw.(string), level) | ||
if err != nil { | ||
return logical.ErrorResponse(fmt.Sprintf("invalid params: %s", err.Error())), nil | ||
name := nameRaw.(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Do we need to check if name is an empty string here the same as above functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding some of the godoc/comments etc. much appreciated.
@@ -112,6 +112,8 @@ func ParseLogFormat(format string) (LogFormat, error) { | |||
} | |||
} | |||
|
|||
// ParseLogLevel returns the hclog.Level that corresponds with the provided level string. | |||
// This differs hclog.LevelFromString in that it supports additional level strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I took this code and refactored it into a function when adding the log file feature, so this is my bad and thanks for adding comments!
However, I think that the func should probably not include notice
or warning
as that hasn't (to my knowledge) been documented on our site.
There's also differing info depending on whether you look at the docs for the server
command or Vault configuration.
Trace, Debug, Error, Warn, Info.
vs trace, debug, info, warn, *err*
.
My PR I have open at the moment to add rotation to log files has updates to the docs to make them all standardised, and I will also update ParseLogLevel
to not handle notice
, warning
or ""
which defaults to info
.
* add logger->log-level str func * ensure SetLogLevelByName accounts for duplicates * add read handlers for sys/loggers endpoints * add changelog entry * update docs * ignore base logger * fix docs formatting issue * add ReadOperation support to TestSystemBackend_Loggers * add more robust checks to TestSystemBackend_Loggers * add more robust checks to TestSystemBackend_LoggersByName * check for empty name in delete handler
* add initial logging helper package * VAULT-9427: Add read support to `sys/loggers` endpoints (#17979) * add logger->log-level str func * ensure SetLogLevelByName accounts for duplicates * add read handlers for sys/loggers endpoints * add changelog entry * update docs * ignore base logger * fix docs formatting issue * add ReadOperation support to TestSystemBackend_Loggers * add more robust checks to TestSystemBackend_Loggers * add more robust checks to TestSystemBackend_LoggersByName * check for empty name in delete handler * add logfile * remove doc changes
PR #16111 added support to modify server logging verbosity both globally and for individual loggers. It did not, however, add the ability to read the current state of the logger verbosity levels. This PR introduces read handlers for the
sys/loggers
andsys/loggers/:name
endpoints.Additional more low-level changes:
Core.SetLogLevelByName
to account for the potential ofCore.allLoggers
including loggers that share the same namesys/loggers
handlers to useParseLogLevel
from the logging helper package to remove redundant codesys/loggers
endpoints do not handle base logger (name ==""
)TranslateLoggerLevel
func to the logging helper package to determine the logging verbosity of anhclog.Logger
Example output on a dev server (
vault server -dev
):