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
syslog-ng-ctl config to print pre-processed configuration #2280
Conversation
This is a good idea, but is it also that it gives you the preprocessed configuration? I would have the assumption that it would return the one that matches the disk file. OTOH, it is true, that include files wouldn't be part of that, whereas this one contains them. In that case, I think I would rename the syslog-ng-ctl command to reflect this fact, e.g. syslog-ng-ctl preprocessed-config (which I don't like too much) or running-config (if that's enough to indicate that it might not be equal to disk file) or something else. the key that it should be clear that it is different. |
I was thinking about to make it possible to provide the original configuration and in such case add an additional option to It was a quick patch, I did not want to complicate things. But you have a valid point, this should be cleared now. Does this alternatives look good to you ? This syntax would support an option like |
Build SUCCESS |
b24819a
to
1546f25
Compare
Build SUCCESS |
lib/cfg.c
Outdated
gsize res; | ||
GString *result = g_string_new(""); | ||
|
||
while ((res = fread(buf, 1, sizeof(buf), fd)) > 0) |
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.
Optional:
If the goal is just to read the content, you could use g_file_get_contents
.
https://developer.gnome.org/glib/stable/glib-File-Utilities.html#g-file-get-contents
Though in the end you need GString
, though I would still use a library function to read into cstring, then convert to glib, as it would result in cleaner code, and performance is not important here.
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, actually I wanted to get such function but my query was not successful, and I did not try that hard.
lib/cfg.c
Outdated
|
||
lexer = cfg_lexer_new_buffer(self, config_string, strlen(config_string)); | ||
lexer->preprocess_output = preprocess_output; | ||
if (!fd) |
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.
It would be nice to log the reason here.
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.
The file is opened again where the reason not able to open a file is logged. I wanted to avoid logging the same thing twice (the two open's result could differ, but I think that has a low chanse, while this failing this open is not critical, while the other is.)
Signed-off-by: Kokan <kokaipeter@gmail.com>
Signed-off-by: Kokan <kokaipeter@gmail.com>
Signed-off-by: Kokan <kokaipeter@gmail.com>
Signed-off-by: Kokan <kokaipeter@gmail.com>
1546f25
to
ed4371c
Compare
Build SUCCESS |
Currently there is no way to tell what configuration syslog-ng has in effect.
Sure the file in the disk can be checked, and most of the time it would be save to assume the active config and the disk content are equal.
This gives an opportunity to both get the content of the top level configuration file and also the preprocessed configuration.
The way it could be queried via
syslog-ng-ctl
:This prints the top level configuration file:
With an option
--preprocess
it prints the preprocessed version of the config: