Skip to content
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

Add 'log-format' CLI flag, along with associated config flag, for 'vault server' command. #6840

Merged
merged 11 commits into from
Jul 18, 2019

Conversation

mjarmy
Copy link
Contributor

@mjarmy mjarmy commented Jun 6, 2019

Add a log-format CLI flag that can specify either "standard" or "json" for the log format for the vault server command. Also add a log_format config file flag that does the same thing. If the format is not specified, then standard log format is used.

We already had the ability to specify this via an environment variable. Note that unlike some of the other environment variable flags, the definition of how json format is enabled is rather permissive, since it allows two different names for the variable, and a few different names for json format. This has been preserved for backwards compatibility. See https://github.com/hashicorp/vault/blob/issue-6796/sdk/helper/logging/logging.go#L67-L81

The precedence of the flags for this setting is CLI, then env var, then config file.

This pull request address issue #6796

@hashicorp-cla
Copy link

hashicorp-cla commented Jun 6, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@catsby catsby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like ParseEnvLogFormat is untested, do you think it's necessary to test it? I only see it used (in these files at least) when called from NewVaultLoggerWithWriter (which is also untested, but as a simple New* function I'm not worried about it)

@jefferai jefferai added this to the 1.2 milestone Jul 2, 2019
@jefferai jefferai added beta and removed beta labels Jul 2, 2019
Copy link
Contributor

@tyrannosaurus-becks tyrannosaurus-becks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good, just a couple of minor questions.

command/server.go Show resolved Hide resolved
sdk/helper/logging/logging.go Show resolved Hide resolved
website/source/docs/configuration/index.html.md Outdated Show resolved Hide resolved
command/server.go Outdated Show resolved Hide resolved
@tyrannosaurus-becks tyrannosaurus-becks self-assigned this Jul 3, 2019
@mjarmy
Copy link
Contributor Author

mjarmy commented Jul 8, 2019

@catsby It was a good idea to add a test for ParseEnvLogFormat(), so I did that

Copy link
Contributor

@tyrannosaurus-becks tyrannosaurus-becks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I tested adding log_format = json to my config file, and I also tried the env var and CLI parameter. I also tried configuring various empty strings, and they defaulted to standard, and I tried doing it without any designation. Everything worked as expected. Good work!

@mjarmy mjarmy merged commit be3e2a1 into master Jul 18, 2019
@mjarmy mjarmy mentioned this pull request Jul 18, 2019
@mjarmy mjarmy deleted the issue-6796 branch October 9, 2019 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants