Pull logging prefix from program name from argv[0]
This commit is contained in:
parent
a1397c53dc
commit
6373580830
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
|
|
||||||
|
extern char log_prefix[64];
|
||||||
|
|
||||||
void vguacd_log_info(const char* format, va_list args);
|
void vguacd_log_info(const char* format, va_list args);
|
||||||
void vguacd_log_error(const char* format, va_list args);
|
void vguacd_log_error(const char* format, va_list args);
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
|
||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
#include <guacamole/error.h>
|
#include <guacamole/error.h>
|
||||||
@ -227,6 +228,10 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set up logging prefix */
|
||||||
|
strncpy(log_prefix, basename(argv[0]), sizeof(log_prefix));
|
||||||
|
|
||||||
|
|
||||||
/* Get addresses for binding */
|
/* Get addresses for binding */
|
||||||
if ((retval = getaddrinfo(listen_address, listen_port, &hints, &addresses))) {
|
if ((retval = getaddrinfo(listen_address, listen_port, &hints, &addresses))) {
|
||||||
guacd_log_error("Error parsing given address or port: %s",
|
guacd_log_error("Error parsing given address or port: %s",
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
#include <guacamole/error.h>
|
#include <guacamole/error.h>
|
||||||
|
|
||||||
|
/* Log prefix, defaulting to "guacd" */
|
||||||
|
char log_prefix[64] = "guacd";
|
||||||
|
|
||||||
void vguacd_log_info(const char* format, va_list args) {
|
void vguacd_log_info(const char* format, va_list args) {
|
||||||
|
|
||||||
/* Copy log message into buffer */
|
/* Copy log message into buffer */
|
||||||
@ -55,7 +58,7 @@ void vguacd_log_info(const char* format, va_list args) {
|
|||||||
syslog(LOG_INFO, "%s", message);
|
syslog(LOG_INFO, "%s", message);
|
||||||
|
|
||||||
/* Log to STDERR */
|
/* Log to STDERR */
|
||||||
fprintf(stderr, "guacd[%i]: INFO: %s\n", getpid(), message);
|
fprintf(stderr, "%s[%i]: INFO: %s\n", log_prefix, getpid(), message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +72,7 @@ void vguacd_log_error(const char* format, va_list args) {
|
|||||||
syslog(LOG_ERR, "%s", message);
|
syslog(LOG_ERR, "%s", message);
|
||||||
|
|
||||||
/* Log to STDERR */
|
/* Log to STDERR */
|
||||||
fprintf(stderr, "guacd[%i]: ERROR: %s\n", getpid(), message);
|
fprintf(stderr, "%s[%i]: ERROR: %s\n", log_prefix, getpid(), message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user