-
Notifications
You must be signed in to change notification settings - Fork 477
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
Fix error reporting of templates #3660
Conversation
Build SUCCESS |
d60a489
to
78296d9
Compare
@kira-syslogng do stresstest |
Build SUCCESS |
Kira-stress-test: Build SUCCESS |
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.
Thanks.
78296d9
to
7866631
Compare
Signed-off-by: László Várady <[email protected]>
7866631
to
c2d3417
Compare
Build SUCCESS |
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.
Besides a minor thing, approve. 👍
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
When using the standard log_template_format() call, empty templates are formatted into empty strings. This can be considered trivial, and log_template_get_trivial_value() should produce the same output. Signed-off-by: László Várady <[email protected]>
These methods can be used to determine whether the template contains only literal values. Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Literal strings are trivial, but instead of hard-coding this fact, compile_literal_string() calls _calculate_triviality(), so the rules of triviality are listed in one place. Signed-off-by: László Várady <[email protected]>
file("/tmp/${DATE"); Previously, the above config snippet created the following file structure: $ tree . error in template: / └── tmp └── ${DATE Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
c2d3417
to
168bb17
Compare
Build SUCCESS |
log_template_compile()
has a return value, which can indicate compilation error.Unfortunately, the return value was not checked in several places, producing repeated run-time errors and unexpected behavior.
For example:
The above config snippet created a file named
${DATE
inside the following directory structure:This is because the
log_template_format()
method called on an invalid template will contain the error itself (error in template: ...
).This PR adds proper error handling where templates are used, or where possible, just replaces the template creation logic with the
template_content
grammar rule, which takes care of error reporting:The PR contains some additional unit tests for non-trivial templates, and also makes empty templates (
template("")
) trivial and addslog_template_is_literal_string()
, so we can get rid of thestrchr($)
trickery in the file destination.