Ensure both logger and syslogd output the same version string

Slight differences in output when called with `-v` flag:

  - Should output to stdout, that's what people expect (not an error)
  - Should output *project* name and version, for syslogd this is not
    so obvious since it *logs* 'syslogd vx.y.z' while the version is
    'sysklogd vx.y.z'

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-08-01 13:17:01 +02:00
parent 7850591388
commit 6bc8525a8d
2 changed files with 5 additions and 3 deletions

View File

@ -366,7 +366,7 @@ int main(int argc, char *argv[])
break; break;
case 'v': /* version */ case 'v': /* version */
fprintf(stderr, "%s\n", version_info); printf("%s\n", version_info);
return 0; return 0;
default: default:

View File

@ -107,6 +107,8 @@ static volatile sig_atomic_t debugging_on;
static volatile sig_atomic_t restart; static volatile sig_atomic_t restart;
static volatile sig_atomic_t rotate_signal; static volatile sig_atomic_t rotate_signal;
static const char version_info[] = PACKAGE_NAME " v" PACKAGE_VERSION;
/* /*
* Intervals at which we flush out "message repeated" messages, * Intervals at which we flush out "message repeated" messages,
* in seconds after previous message is logged. After each flush, * in seconds after previous message is logged. After each flush,
@ -494,8 +496,8 @@ int main(int argc, char *argv[])
break; break;
case 'v': case 'v':
printf("syslogd v%s\n", VERSION); printf("%s\n", version_info);
exit(0); return 0;
case '?': case '?':
return usage(0); return usage(0);