* Use our own logging mechanism instead of syslog/printf.

This commit is contained in:
Justin Maggard
2009-02-20 10:21:23 +00:00
parent 69965b876e
commit 45f294b404
16 changed files with 482 additions and 338 deletions

View File

@ -11,12 +11,13 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include "daemonize.h"
#include "config.h"
#include "log.h"
#ifndef USE_DAEMON
@ -72,22 +73,22 @@ writepidfile(const char * fname, int pid)
if( (pidfile = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0)
{
syslog(LOG_ERR, "Unable to open pidfile for writing %s: %m", fname);
DPRINTF(E_ERROR, L_GENERAL, "Unable to open pidfile for writing %s: %s\n", fname, strerror(errno));
return -1;
}
pidstringlen = snprintf(pidstring, sizeof(pidstring), "%d\n", pid);
if(pidstringlen <= 0)
{
syslog(LOG_ERR,
"Unable to write to pidfile %s: snprintf(): FAILED", fname);
DPRINTF(E_ERROR, L_GENERAL,
"Unable to write to pidfile %s: snprintf(): FAILED\n", fname);
close(pidfile);
return -1;
}
else
{
if(write(pidfile, pidstring, pidstringlen) < 0)
syslog(LOG_ERR, "Unable to write to pidfile %s: %m", fname);
DPRINTF(E_ERROR, L_GENERAL, "Unable to write to pidfile %s: %s\n", fname, strerror(errno));
}
close(pidfile);