You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose to change such bunch of code with the err(3) set of functions, like errx. Advantages:
it will bring coherency around the code
makes the code a little more readable
no need for the extra new line at the end of the string
provides automatically short application name in front of the message, as for example
$ pgagroal
pgagroal: Server section [a] duplicated at lines 15 and 19 of file </etc/pgagroal/pgagroal.conf>
pgagroal: 1 problematic or duplicated sections (file </etc/pgagroal/pgagroal.conf>)
$ /usr/local/bin/pgagroal
pgagroal: Server section [a] duplicated at lines 15 and 19 of file </etc/pgagroal/pgagroal.conf>
pgagroal: 1 problematic or duplicated sections (file </etc/pgagroal/pgagroal.conf>)
The pgagroal: part is automatically appended even if the application is invoked with a full path, so we can remove it (and forget about it) from every message.
The text was updated successfully, but these errors were encountered:
fluca1978
added a commit
to fluca1978/pgagroal
that referenced
this issue
Aug 24, 2022
Whenever in the code there is a `printf` + `exit` or similar piece of
code, use `err(3)` functions instead.
This brings coherency, removes the need for the extra new line, the
program name and provides automatic expansion of errors when needed.
This also changes the `create_pidfile` sttic function so that it
terminates the current program (main) if the pid file cannot be
created. To emphasize this, the function has been renamed to
`create_pidfile_or_exit`. Also the `remove_pidfile` changed to emit a
warning if the pid file cannot be removed
Closeagroal#316
There is a lot of code that contains
printf
orfprintf(stderr)
andexit
(e.g., https://github.com/agroal/pgagroal/blob/master/src/main.c#L528).I propose to change such bunch of code with the
err(3)
set of functions, likeerrx
. Advantages:The
pgagroal:
part is automatically appended even if the application is invoked with a full path, so we can remove it (and forget about it) from every message.The text was updated successfully, but these errors were encountered: