mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
cwmp: Updated syslogs
This commit is contained in:
parent
943c3dfe39
commit
1b5b3b3f8d
2 changed files with 5 additions and 13 deletions
4
cwmp.c
4
cwmp.c
|
|
@ -16,6 +16,7 @@
|
|||
#include <math.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "session.h"
|
||||
|
|
@ -701,6 +702,8 @@ int main(int argc, char **argv)
|
|||
sigset_t set;
|
||||
int error;
|
||||
|
||||
openlog("cwmp", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
|
||||
|
||||
if ((error = cwmp_init(argc, argv, cwmp)))
|
||||
return error;
|
||||
|
||||
|
|
@ -794,5 +797,6 @@ int main(int argc, char **argv)
|
|||
cwmp_free(cwmp);
|
||||
|
||||
CWMP_LOG(INFO, "EXIT ICWMP");
|
||||
closelog();
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
|
|
|||
14
log.c
14
log.c
|
|
@ -81,19 +81,10 @@ int log_set_on_file(char *value)
|
|||
return 1;
|
||||
}
|
||||
|
||||
extern char *__progname;
|
||||
|
||||
int log_set_on_syslog(char *value)
|
||||
{
|
||||
if ((strcasecmp(value, "TRUE") == 0) || (strcmp(value, "1") == 0) || (strcasecmp(value, "enable") == 0)) {
|
||||
char ident[256];
|
||||
|
||||
enable_log_syslog = true;
|
||||
|
||||
setlogmask(LOG_UPTO(log_severity));
|
||||
snprintf(ident, sizeof(ident), "%s[%d]", __progname, getpid());
|
||||
ident[sizeof(ident) - 1] = '\0';
|
||||
openlog(ident, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
|
||||
} else {
|
||||
enable_log_syslog = false;
|
||||
}
|
||||
|
|
@ -155,11 +146,8 @@ void puts_log(int severity, const char *fmt, ...)
|
|||
|
||||
if (enable_log_syslog) {
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, strlen(buf), fmt, args);
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
vsyslog(severity, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
syslog(severity, "%s", buf);
|
||||
}
|
||||
end:
|
||||
pthread_mutex_unlock(&mutex_log);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue