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

Logging policy #856

Merged
merged 5 commits into from Aug 28, 2018
Merged

Logging policy #856

merged 5 commits into from Aug 28, 2018

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Aug 27, 2018

Allows enabling/disabling access logs per service, so addresses #712 partially.

@davidor davidor requested a review from a team as a code owner August 27, 2018 17:26

-- Returns the value for ngx.var.enable_acess_logs
local function enable_access_log_value(enabled)
return (enabled and '1') or '0'
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to use dispatch table for this. Conditionals are not JITable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, it doesn't matter much, because it's only called from new().
But I changed it because as a general rule we should do this, and I tend to forget about this 😅

@@ -120,7 +120,8 @@ http {

server {

access_log {{ access_log_file | default: "/dev/stdout" }} time;
set $enable_access_logs '1';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather name it access_logs_enabled so we can later have access_logs_format etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good 👍

@davidor davidor changed the title [WIP] Logging policy Logging policy Aug 28, 2018
@davidor davidor force-pushed the logging-policy branch 2 times, most recently from c3e0f49 to 3310f92 Compare August 28, 2018 10:27
@@ -120,7 +120,8 @@ http {

server {

access_log {{ access_log_file | default: "/dev/stdout" }} time;
set $access_logs_enabled '1';
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure about the quotes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's correct. From the docs:
The if parameter (1.7.0) enables conditional logging. A request will not be logged if the condition evaluates to “0” or an empty string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. But what I meant is that set value should not be quoted. Now the value is '1', not 1.
It is a bit confusing (even though it will still work).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I wanted it to be a string because the docs mention "0" as a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So just to be clear, I inspected the value of the ngx.var and it's the string "1", not the string "'1'". Not sure if that's what you meant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. There is some magic going on.

Both these are the same value (string):

    set $access_log_enabled '1';
    set $access_log_enabled_num 1;

I thought we had a PR to strip '' from some of the values because it was generating quotes. My bad I guess.

@mikz mikz mentioned this pull request Aug 28, 2018
4 tasks
Copy link
Contributor

@mikz mikz left a comment

Choose a reason for hiding this comment

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

👍

@davidor davidor merged commit 1df0947 into master Aug 28, 2018
@davidor davidor deleted the logging-policy branch August 28, 2018 12:35
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.

None yet

2 participants