Split logging functions into separate files
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <syslog.h>
|
||||
#include <getopt.h>
|
||||
#include <confuse.h>
|
||||
|
||||
#include "yasnd.h"
|
||||
#include "yasnd-log.h"
|
||||
#include "yasnd-lpt.h"
|
||||
|
||||
cfg_t *cfg; // pointer to configuration structure
|
||||
char pidfile[]="/var/run/yasnd.pid"; // pidfile path
|
||||
host_decl* hosts=NULL; // structure with hosts' definitions
|
||||
int hosts_count=0; // count of hosts
|
||||
int debug_flag=0;
|
||||
bool sms_enable=false; // use SMS messages for control and reports?
|
||||
char* phone_device=NULL; // phone device for gammu, for example: "/dev/ttyACM0"
|
||||
char* phone_model=NULL; // gammu phone model, for example: "at"
|
||||
@@ -24,17 +23,6 @@ int failures_second=0; // count of failures while hosts checking, that triggers
|
||||
int failures_third=0; // count of failures while hosts checking, that clean failure statistics
|
||||
pid_t mainloop_clone_pid; // pid of clone process, that containt main loop
|
||||
|
||||
void log_debug(const char *message,int verbosity)
|
||||
{
|
||||
if (debug_flag>=verbosity)
|
||||
syslog(LOG_INFO,"%s",message);
|
||||
}
|
||||
|
||||
void log_event(const char *message)
|
||||
{
|
||||
syslog(LOG_INFO,"%s",message);
|
||||
}
|
||||
|
||||
void* allocate_memory(int bytes)
|
||||
{
|
||||
void* result=malloc(bytes);
|
||||
@@ -301,7 +289,7 @@ void signal_handler(int signum)
|
||||
// block LPT control circuit
|
||||
lpt_lock();
|
||||
// close log decriptor
|
||||
closelog();
|
||||
log_close();
|
||||
//
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -350,7 +338,7 @@ int main(int argc, char *argv[])
|
||||
umask(0);
|
||||
|
||||
/* Open any logs here */
|
||||
openlog("yasnd", LOG_PID|LOG_CONS, LOG_USER);
|
||||
log_init();
|
||||
|
||||
/* Create a new SID for the child process */
|
||||
sid = setsid();
|
||||
|
||||
Reference in New Issue
Block a user