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 <math.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
|
|
@ -701,6 +702,8 @@ int main(int argc, char **argv)
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
openlog("cwmp", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
|
||||||
|
|
||||||
if ((error = cwmp_init(argc, argv, cwmp)))
|
if ((error = cwmp_init(argc, argv, cwmp)))
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|
@ -794,5 +797,6 @@ int main(int argc, char **argv)
|
||||||
cwmp_free(cwmp);
|
cwmp_free(cwmp);
|
||||||
|
|
||||||
CWMP_LOG(INFO, "EXIT ICWMP");
|
CWMP_LOG(INFO, "EXIT ICWMP");
|
||||||
|
closelog();
|
||||||
return CWMP_OK;
|
return CWMP_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
log.c
14
log.c
|
|
@ -81,19 +81,10 @@ int log_set_on_file(char *value)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char *__progname;
|
|
||||||
|
|
||||||
int log_set_on_syslog(char *value)
|
int log_set_on_syslog(char *value)
|
||||||
{
|
{
|
||||||
if ((strcasecmp(value, "TRUE") == 0) || (strcmp(value, "1") == 0) || (strcasecmp(value, "enable") == 0)) {
|
if ((strcasecmp(value, "TRUE") == 0) || (strcmp(value, "1") == 0) || (strcasecmp(value, "enable") == 0)) {
|
||||||
char ident[256];
|
|
||||||
|
|
||||||
enable_log_syslog = true;
|
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 {
|
} else {
|
||||||
enable_log_syslog = false;
|
enable_log_syslog = false;
|
||||||
}
|
}
|
||||||
|
|
@ -155,11 +146,8 @@ void puts_log(int severity, const char *fmt, ...)
|
||||||
|
|
||||||
if (enable_log_syslog) {
|
if (enable_log_syslog) {
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(buf, strlen(buf), fmt, args);
|
vsyslog(severity, fmt, args);
|
||||||
buf[sizeof(buf) - 1] = '\0';
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
syslog(severity, "%s", buf);
|
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
pthread_mutex_unlock(&mutex_log);
|
pthread_mutex_unlock(&mutex_log);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue