mirror of
https://github.com/coturn/coturn.git
synced 2025-10-27 13:00:59 +01:00
Add syslog facility configuration
This commit is contained in:
parent
553ce02168
commit
22af3ea567
@ -528,6 +528,11 @@
|
||||
#
|
||||
#syslog
|
||||
|
||||
# Set syslog facility for syslog messages
|
||||
# Default values is ''.
|
||||
#
|
||||
#syslog-facility="LOG_LOCAL1"
|
||||
|
||||
# This flag means that no log file rollover will be used, and the log file
|
||||
# name will be constructed as-is, without PID and date appendage.
|
||||
# This option can be used, for example, together with the logrotate tool.
|
||||
|
||||
@ -147,6 +147,48 @@ int turn_mutex_destroy(turn_mutex* mutex) {
|
||||
|
||||
///////////////////////// LOG ///////////////////////////////////
|
||||
|
||||
/* syslog facility */
|
||||
/*BVB-594 Syslog facility */
|
||||
static char* str_fac[]={"LOG_AUTH","LOG_CRON","LOG_DAEMON",
|
||||
"LOG_KERN","LOG_LOCAL0","LOG_LOCAL1",
|
||||
"LOG_LOCAL2","LOG_LOCAL3","LOG_LOCAL4","LOG_LOCAL5",
|
||||
"LOG_LOCAL6","LOG_LOCAL7","LOG_LPR","LOG_MAIL",
|
||||
"LOG_NEWS","LOG_USER","LOG_UUCP",
|
||||
"LOG_AUTHPRIV","LOG_FTP","LOG_SYSLOG",
|
||||
0};
|
||||
|
||||
static int int_fac[]={LOG_AUTH , LOG_CRON , LOG_DAEMON ,
|
||||
LOG_KERN , LOG_LOCAL0 , LOG_LOCAL1 ,
|
||||
LOG_LOCAL2 , LOG_LOCAL3 , LOG_LOCAL4 , LOG_LOCAL5 ,
|
||||
LOG_LOCAL6 , LOG_LOCAL7 , LOG_LPR , LOG_MAIL ,
|
||||
LOG_NEWS , LOG_USER , LOG_UUCP,
|
||||
LOG_AUTHPRIV,LOG_FTP,LOG_SYSLOG,
|
||||
0};
|
||||
|
||||
static int syslog_facility = 0;
|
||||
|
||||
static int str2facility(char *s)
|
||||
{
|
||||
int i;
|
||||
for (i=0; str_fac[i]; i++) {
|
||||
if (!strcasecmp(s,str_fac[i]))
|
||||
return int_fac[i];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void set_syslog_facility(char *val)
|
||||
{
|
||||
if(val == NULL){
|
||||
return;
|
||||
}
|
||||
int tmp = str2facility(val);
|
||||
if(tmp == -1){
|
||||
return;
|
||||
}
|
||||
syslog_facility = tmp;
|
||||
}
|
||||
|
||||
#if defined(TURN_LOG_FUNC_IMPL)
|
||||
extern void TURN_LOG_FUNC_IMPL(TURN_LOG_LEVEL level, const char* format, va_list args);
|
||||
#endif
|
||||
@ -510,7 +552,7 @@ void turn_log_func_default(TURN_LOG_LEVEL level, const char* format, ...)
|
||||
fwrite(s, so_far, 1, stdout);
|
||||
/* write to syslog or to log file */
|
||||
if(to_syslog) {
|
||||
syslog(get_syslog_level(level),"%s",s);
|
||||
syslog(syslog_facility|get_syslog_level(level),"%s",s);
|
||||
} else {
|
||||
log_lock();
|
||||
set_rtpfile();
|
||||
|
||||
@ -61,6 +61,8 @@ void set_no_stdout_log(int val);
|
||||
void set_log_to_syslog(int val);
|
||||
void set_simple_log(int val);
|
||||
|
||||
void set_syslog_facility(char *val);
|
||||
|
||||
void set_turn_log_timestamp_format(char* new_format);
|
||||
|
||||
void turn_log_func_default(TURN_LOG_LEVEL level, const char* format, ...);
|
||||
|
||||
@ -620,6 +620,7 @@ static char Usage[] = "Usage: turnserver [options]\n"
|
||||
" a log file. With this option everything will be going to the log file only\n"
|
||||
" (unless the log file itself is stdout).\n"
|
||||
" --syslog Output all log information into the system log (syslog), do not use the file output.\n"
|
||||
" --syslog-facility <value> Set syslog facility for syslog messages. Default is ''.\n"
|
||||
" --simple-log This flag means that no log file rollover will be used, and the log file\n"
|
||||
" name will be constructed as-is, without PID and date appendage.\n"
|
||||
" This option can be used, for example, together with the logrotate tool.\n"
|
||||
@ -796,6 +797,7 @@ enum EXTRA_OPTS {
|
||||
AUTH_SECRET_TS_EXP, /* deprecated */
|
||||
NO_STDOUT_LOG_OPT,
|
||||
SYSLOG_OPT,
|
||||
SYSLOG_FACILITY_OPT,
|
||||
SIMPLE_LOG_OPT,
|
||||
NEW_LOG_TIMESTAMP_OPT,
|
||||
NEW_LOG_TIMESTAMP_FORMAT_OPT,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user