Named Log Entries in the Config File
Hello, I am writing a program to make updates tho the syslog-ng configuration file. To allow for easily adding and removing log entries, I updated the parser gramer to allow a name field in the log entry. The name is optional, so old log files will still work. This name is not used by syslog-ng in any way. Example: Both log entries below are valid with my grammar update. log { source(s_all); filter(f_syslog); destination(df_syslog); }; log l_syslog { source(s_all); filter(f_syslog); destination(df_syslog); }; A patch generated with the following command is attached: "diff -uprN src/cfg-grammar.y.org src/cfg-grammar.y > ~/cfg-grammar.y.diff" --- src/cfg-grammar.y.org 2006-01-04 11:04:19.000000000 -0500 +++ src/cfg-grammar.y 2006-01-04 11:06:08.000000000 -0500 @@ -113,6 +113,8 @@ LogTemplate *last_template; %type <ptr> source_stmt %type <ptr> dest_stmt %type <ptr> log_stmt +%type <ptr> log_stmt_name +%type <ptr> log_stmt_noname %type <ptr> options_stmt %type <ptr> template_stmt @@ -202,7 +204,16 @@ dest_stmt ; log_stmt - : '{' log_items log_flags '}' { $$ = log_connection_new($2, $3); } + : log_stmt_noname { $$ = $1; } + | log_stmt_name { $$ = $1; } + ; + +log_stmt_name + : string '{' log_items log_flags '}' { $$ = make_log_connection($3, $4); } + ; + +log_stmt_noname + : '{' log_items log_flags '}' { $$ = make_log_connection($2, $3); } ; options_stmt
I forgot to mention. My diff is based on the source from syslog-ng-1.9.8+20060104.tar.gz -Ken Kenneth Kassing wrote:
Hello, I am writing a program to make updates tho the syslog-ng configuration file. To allow for easily adding and removing log entries, I updated the parser gramer to allow a name field in the log entry. The name is optional, so old log files will still work. This name is not used by syslog-ng in any way.
Example: Both log entries below are valid with my grammar update.
log { source(s_all); filter(f_syslog); destination(df_syslog); };
log l_syslog { source(s_all); filter(f_syslog); destination(df_syslog); };
A patch generated with the following command is attached: "diff -uprN src/cfg-grammar.y.org src/cfg-grammar.y > ~/cfg-grammar.y.diff"
------------------------------------------------------------------------
--- src/cfg-grammar.y.org 2006-01-04 11:04:19.000000000 -0500 +++ src/cfg-grammar.y 2006-01-04 11:06:08.000000000 -0500 @@ -113,6 +113,8 @@ LogTemplate *last_template; %type <ptr> source_stmt %type <ptr> dest_stmt %type <ptr> log_stmt +%type <ptr> log_stmt_name +%type <ptr> log_stmt_noname %type <ptr> options_stmt %type <ptr> template_stmt
@@ -202,7 +204,16 @@ dest_stmt ;
log_stmt - : '{' log_items log_flags '}' { $$ = log_connection_new($2, $3); } + : log_stmt_noname { $$ = $1; } + | log_stmt_name { $$ = $1; } + ; + +log_stmt_name + : string '{' log_items log_flags '}' { $$ = make_log_connection($3, $4); } + ; + +log_stmt_noname + : '{' log_items log_flags '}' { $$ = make_log_connection($2, $3); } ;
options_stmt
------------------------------------------------------------------------
_______________________________________________ syslog-ng maillist - syslog-ng@lists.balabit.hu https://lists.balabit.hu/mailman/listinfo/syslog-ng Frequently asked questions at http://www.campin.net/syslog-ng/faq.html
Kenneth Kassing wrote:
Hello, I am writing a program to make updates tho the syslog-ng configuration file. To allow for easily adding and removing log entries, I updated the parser gramer to allow a name field in the log entry. The name is optional, so old log files will still work. This name is not used by syslog-ng in any way.
Example: Both log entries below are valid with my grammar update.
log { source(s_all); filter(f_syslog); destination(df_syslog); };
log l_syslog { source(s_all); filter(f_syslog); destination(df_syslog); };
You could use another approach (without patching syslog-ng), using only comments: #<BEGIN l_syslog> ... #<END l_syslog> I used a similar approach for adding/removing sources, destinations and filters. My update tool was sed :)) -- Sandor Geller wildy@balabit.hu
Sandor Geller wrote:
Kenneth Kassing wrote:
Hello, I am writing a program to make updates tho the syslog-ng configuration file. To allow for easily adding and removing log entries, I updated the parser gramer to allow a name field in the log entry. The name is optional, so old log files will still work. This name is not used by syslog-ng in any way.
Example: Both log entries below are valid with my grammar update.
log { source(s_all); filter(f_syslog); destination(df_syslog); };
log l_syslog { source(s_all); filter(f_syslog); destination(df_syslog); };
You could use another approach (without patching syslog-ng), using only comments:
#<BEGIN l_syslog> ... #<END l_syslog>
I used a similar approach for adding/removing sources, destinations and filters. My update tool was sed :))
That is an approach I had not thought of. However, I like the name field in the log option as it remains parallel with the existing config log. This could conceivably be adopted and used by syslog-ng itself in the future. Additionally, I am using a grammar parser written in python to read in the config file. Currently it is configured to ignore all the comments. Adding a special comment to the grammar would significantly complicate the logic I am using. Thanks -Ken
On Thu, 2006-01-05 at 15:05 -0500, Kenneth Kassing wrote:
Sandor Geller wrote:
Kenneth Kassing wrote:
That is an approach I had not thought of. However, I like the name field in the log option as it remains parallel with the existing config log. This could conceivably be adopted and used by syslog-ng itself in the future.
Additionally, I am using a grammar parser written in python to read in the config file. Currently it is configured to ignore all the comments. Adding a special comment to the grammar would significantly complicate the logic I am using.
This time I agree with Sandor, as long as this name is not needed by syslog-ng itself I'm reluctant to include it in the grammar. -- Bazsi
participants (3)
-
Balazs Scheidler
-
Kenneth Kassing
-
Sandor Geller