I'm about to implement configuration file includes, and although the implementation is quite straightforward, the syntax to be used is something to give a thought or two.
Currently the syslog-ng configuration file consists of statements, each with the following basic format:
stmt [] { ... };
The "id" gives a unique identifier of the statement, and the braces enclose the contents. Currently only the ID part is optional, the braces are always there.
To make the include statement consistent with that, it'd have to look something like:
include { "filename" };
Obviously I don't like this too much, as it is way different from all other applications permitting the use of include statements. What about this:
include "filename";
E.g. use the ID part the name of the file to be included. I like this better. A third option might be the use of 'pragma' directives, currently only used to specify the file format compatibility in the case of syslog-ng 3.0:
@version: 3.0
This'd mean that include statements would look like this:
@include: filename
The problem with this last option is that pragmas are currently only processed at the beginning of the configuration file. So that code should also be generalized.
I think I'd go with the second option, that's not completely inconsistent, but still the most intuitive to use.
What do you think?
Currently the syslog-ng configuration file consists of statements, each with the following basic format:
stmt [
The "id" gives a unique identifier of the statement, and the braces enclose the contents. Currently only the ID part is optional, the braces are always there.
To make the include statement consistent with that, it'd have to look something like:
include { "filename" };
Obviously I don't like this too much, as it is way different from all other applications permitting the use of include statements. What about this:
include "filename";
E.g. use the ID part the name of the file to be included. I like this better. A third option might be the use of 'pragma' directives, currently only used to specify the file format compatibility in the case of syslog-ng 3.0:
@version: 3.0
This'd mean that include statements would look like this:
@include: filename
The problem with this last option is that pragmas are currently only processed at the beginning of the configuration file. So that code should also be generalized.
I think I'd go with the second option, that's not completely inconsistent, but still the most intuitive to use.
What do you think?
Comments
One advantage of it is that it makes it easy to list multiple files in a way that's consistent with existing syntax. Something like:
include { "filename1";
"filename2";
};
Or, maybe even:
include { file("filename1");
file("filename2");
directory("/etc/syslog-ng/inc/"); };
if you wanted to include an include directory. An argument could be made that rather than increasing the complexity of the config with file/directory statements, syslog-ng could just interpret a path that ends in '/' as a directory to include, rather than a file, and I wouldn't necessarily argue against that, either.
Regardless, I can see some definite use for this feature. At my last job, we had a syslog-ng box with a config approaching 1000 lines long. Being able to split it up would have made editing a lot easier.