switch to syslog
This commit is contained in:
18
src/hdbd.c
18
src/hdbd.c
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <syslog.h>
|
||||
|
||||
pid_t pid, sid;
|
||||
int server_sock;
|
||||
@@ -38,17 +39,9 @@ int main() {
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
FILE *out_log;
|
||||
FILE *err_log;
|
||||
/* TODO: switch to mode 'a' later */
|
||||
out_log = fopen("/tmp/out_log.txt", "w");
|
||||
err_log = fopen("/tmp/err_log.txt", "w");
|
||||
if (out_log == NULL || err_log == NULL) {
|
||||
return 1;
|
||||
}
|
||||
openlog("hdbd", LOG_CONS|LOG_PID, LOG_USER);
|
||||
syslog(LOG_INFO, "Hello from hdbd");
|
||||
|
||||
fprintf(err_log, "Hello, World!\n");
|
||||
|
||||
/* Setup Unix Socket */
|
||||
server_sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (server_sock == -1) {
|
||||
@@ -68,8 +61,7 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(out_log, "Listening on %s\n", server.sun_path);
|
||||
|
||||
syslog(LOG_INFO, "Listening for connections...");
|
||||
|
||||
/* Actual program */
|
||||
int client_sock;
|
||||
@@ -102,8 +94,6 @@ int main() {
|
||||
close(client_sock);
|
||||
}
|
||||
|
||||
fclose(out_log);
|
||||
fclose(err_log);
|
||||
close(server_sock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user