Re: [syslog-ng] Creating a "log" block (OSE 3.2.1)
thanks for noticing this error. I've corrected it in the source repo of the adminguide, and will update the docs on the website when someone tells me if using {} within blocks is permitted (but now buggy) or forbidden.
changing the type of the block to root should workaround the problem.
I see, it's really about using { }'s within the block definition. Making it a "root" block (as a completely separately log {} stanza) is probably cleaner in this particular case, but the same restriction applies at the moment -- the example from the OSE 3.2 documentation [5.3.2]: block root mylogs() { source s_file { file("/var/log/mylogs.log" follow_freq(1)); }; destination d_local { file("/var/log/messages"); }; log { source(s_file); destination(d_local); }; }; doesn't parse either (same error on the final "};") The documentation (html/PDF) could use some minor updates in this area for clarity: - block definitions also require ()'s after the name (including non-parameterized); e.g. block root foo() { ... } - perhaps add an additional example for using parameterized blocks; e.g. block destination foo ( logname("some.log") ) { file( "/var/log/`logname`" ... ); }; destination bar { foo( logname("other.log") ) }; destination baz { foo() }; regards, -eric ps: I have yet to actually *test* any of this new functionality myself yet (later today :)
On Wed, 2010-12-08 at 09:37 -0800, Eric Berggren wrote:
thanks for noticing this error. I've corrected it in the source repo of the adminguide, and will update the docs on the website when someone tells me if using {} within blocks is permitted (but now buggy) or forbidden.
changing the type of the block to root should workaround the problem.
I see, it's really about using { }'s within the block definition. Making it a "root" block (as a completely separately log {} stanza) is probably cleaner in this particular case, but the same restriction applies at the moment -- the example from the OSE 3.2 documentation [5.3.2]:
block root mylogs() { source s_file { file("/var/log/mylogs.log" follow_freq(1)); }; destination d_local { file("/var/log/messages"); }; log { source(s_file); destination(d_local); }; };
doesn't parse either (same error on the final "};")
The documentation (html/PDF) could use some minor updates in this area for clarity:
- block definitions also require ()'s after the name (including non-parameterized); e.g. block root foo() { ... } - perhaps add an additional example for using parameterized blocks; e.g. block destination foo ( logname("some.log") ) { file( "/var/log/`logname`" ... ); }; destination bar { foo( logname("other.log") ) }; destination baz { foo() };
regards, -eric ps: I have yet to actually *test* any of this new functionality myself yet (later today :)
Ahh.. this is an independent bug, fixed by this patch: diff --git a/lib/cfg-lex.l b/lib/cfg-lex.l index 34881c6..af4a715 100644 --- a/lib/cfg-lex.l +++ b/lib/cfg-lex.l @@ -254,7 +254,7 @@ word [^ \#'"\(\)\{\}\\;\n\t,|\.@:] } -<block_content>[^}\"\'\n\r]+ { g_string_append(yyextra->string_buffer, yytext); } +<block_content>[^{}\"\'\n\r]+ { g_string_append(yyextra->string_buffer, yytext); } <INITIAL><<EOF>> { if (!cfg_lexer_start_next_include(yyextra)) yyterminate(); } So, the only issue is to solve the multiple ';' problem (although that can be worked around) and you'd have what you aim at. -- Bazsi
On Wed, 2010-12-08 at 09:37 -0800, Eric Berggren wrote:
thanks for noticing this error. I've corrected it in the source repo of the adminguide, and will update the docs on the website when someone tells me if using {} within blocks is permitted (but now buggy) or forbidden.
changing the type of the block to root should workaround the problem.
I see, it's really about using { }'s within the block definition. Making it a "root" block (as a completely separately log {} stanza) is probably cleaner in this particular case, but the same restriction applies at the moment -- the example from the OSE 3.2 documentation [5.3.2]:
block root mylogs() { source s_file { file("/var/log/mylogs.log" follow_freq(1)); }; destination d_local { file("/var/log/messages"); }; log { source(s_file); destination(d_local); }; };
doesn't parse either (same error on the final "};")
The documentation (html/PDF) could use some minor updates in this area for clarity:
- block definitions also require ()'s after the name (including non-parameterized); e.g. block root foo() { ... } - perhaps add an additional example for using parameterized blocks; e.g. block destination foo ( logname("some.log") ) { file( "/var/log/`logname`" ... ); }; destination bar { foo( logname("other.log") ) }; destination baz { foo() };
regards, -eric ps: I have yet to actually *test* any of this new functionality myself yet (later today :)
hi, I've just committed these 3 patches that implement block support for block statements. I've also resolved the '{' issue and also made it possible to use several ';' characters in place of a single one. I believe it is now possible to do what you originally wanted. These are the patches: commit ab88791c912bcba7b5ee9803682317404ea116cd Author: Balazs Scheidler <bazsi@balabit.hu> Date: Thu Dec 9 21:19:08 2010 +0100 blocks: make it possible to use blocks inside log statements The original block implementation lacked support for blocks inside log statements. This patch addresses that, by creating the "log" context for blocks. This is how to use it: block log logblock() { destination(something); flags(flow-control); }; log { logblock(); }; Reported-By: Eric Berggren Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> commit 4d9f15ec70c86aace491527791b4304693f0222b Author: Balazs Scheidler <bazsi@balabit.hu> Date: Thu Dec 9 21:18:57 2010 +0100 blocks: allow the use of '{' character inside blocks This was an omission in one of the lexer rules, but with this fix it works fine. Reported-By: Eric Berggren Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> commit c2dbe6316c9b3afc7ff930c9ffa4cf190a699a09 Author: Balazs Scheidler <bazsi@balabit.hu> Date: Thu Dec 9 21:18:30 2010 +0100 log statements: allow several semicolons instead of one In order to introduce block support within "log" statements, it is convinient to allow several ';' everywhere where only one was permitted. This is needed in order to make it possible to close a statement inside a block with a ';', and then also use a ';' at the end of a block reference. This is more readable. Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> -- Bazsi
On Thu, 2010-12-09 at 13:12 -0800, Matthew Hall wrote:
I've just committed these 3 patches
Hey Bazsi,
What branch(es)?
Matthew.
git://git.balabit.hu/bazsi/syslog-ng-3.2.git "master" branch. I've considered this as a bug in the original blocks implementation, and the patches are not really risky. -- Bazsi
participants (3)
-
Balazs Scheidler
-
Eric Berggren
-
Matthew Hall