Add options to LogAction() so it can append (instead of truncate) and… #4329

Merged
merged 3 commits into from Aug 19, 2016

Projects

None yet

2 participants

@wessels
wessels commented Aug 17, 2016

… write without buffering.

Was so happy to discover LogAction() but disappointed that it truncates
the file each time the process starts, and apparently doesn't flush the
file upon exiting. With two new optional args, the file can be appended
rather than truncated and buffering disabled. The defaults remain as
before, which is to say to truncate and to buffer.

wessels Add options to LogAction() so it can append (instead of truncate) and…
… write without buffering.

Was so happy to discover LogAction() but disappointed that it truncates
the file each time the process starts, and apparently doesn't flush the
file upon exiting.  With two new optional args, the file can be appended
rather than truncated and buffering disabled.  The defaults remain as
before, which is to say to truncate and to buffer.
456fc64
@rgacogne rgacogne and 1 other commented on an outdated diff Aug 18, 2016
pdns/README-dnsdist.md
@@ -1257,7 +1257,7 @@ instantiate a server with additional parameters
* `DelayAction(milliseconds)`: delay the response by the specified amount of milliseconds (UDP-only)
* `DisableValidationAction()`: set the CD bit in the question, let it go through
* `DropAction()`: drop these packets
- * `LogAction([filename], [binary])`: Log a line for each query, to the specified file if any, to the console (require verbose) otherwise. When logging to a file, the `binary` optional parameter specifies whether we log in binary form (default) or in textual form
+ * `LogAction([filename], [binary])`: Log a line for each query, to the specified file if any, to the console (require verbose) otherwise. When logging to a file, the `binary` optional parameter specifies whether we log in binary form (default) or in textual form, the `append` optional parameter specifies whether we open the file for appending or truncate each time (default), and the `buffered` optional parameter specifies whether writes to the file are buffered (default) or not.
@rgacogne
rgacogne Aug 18, 2016 Member

The parameters have not been updated in the prototype here.

@wessels
wessels Aug 18, 2016

Thanks, I missed that. Its added now.

@rgacogne rgacogne and 1 other commented on an outdated diff Aug 18, 2016
pdns/dnsrulactions.hh
@@ -913,6 +918,8 @@ private:
string d_fname;
FILE* d_fp{0};
bool d_binary{true};
+ bool d_append{false};
+ bool d_buffered{true};
@rgacogne
rgacogne Aug 18, 2016 Member

It looks like we don't need to keep d_append and d_buffered around, since they seem to be only used in the constructor.

@wessels
wessels Aug 18, 2016

Yes, thanks for the suggestion.

@rgacogne
Member

Thank you!

@rgacogne rgacogne merged commit 39368ff into PowerDNS:master Aug 19, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment