Skip to content
Snippets Groups Projects
Commit dbd42a64 authored by Mark Spencer's avatar Mark Spencer
Browse files

Apply queuelog patch and perform final test of "test patches" system

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5168 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 2e0cf7a0
No related branches found
No related tags found
No related merge requests found
...@@ -660,7 +660,7 @@ apply: ...@@ -660,7 +660,7 @@ apply:
unapply: unapply:
@if [ -z "$(PATCH)" ]; then \ @if [ -z "$(PATCH)" ]; then \
echo "Usage: make PATCH=<patchname> unapply"; \ echo "Usage: make PATCH=<patchname> unapply"; \
elif !grep -q ^$(PATCH)$$ patches/.applied 2>/dev/null; then \ elif ! grep -q ^$(PATCH)$$ patches/.applied 2>/dev/null; then \
echo "Patch $(PATCH) is not applied"; \ echo "Patch $(PATCH) is not applied"; \
elif [ -f "patches/$(PATCH)" ]; then \ elif [ -f "patches/$(PATCH)" ]; then \
echo "Un-applying patch $(PATCH)"; \ echo "Un-applying patch $(PATCH)"; \
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
; This appends the hostname to the name of the log files. ; This appends the hostname to the name of the log files.
;appendhostname = yes ;appendhostname = yes
; ;
; This determines whether or not we log queue events to a file (defaults to yes).
;queue_log = no
;
; This determines whether or not we log generic events to a file (defaults to yes).
;event_log = no
;
; ;
; For each file, specify what to log. ; For each file, specify what to log.
; ;
......
...@@ -61,6 +61,11 @@ AST_MUTEX_DEFINE_STATIC(loglock); ...@@ -61,6 +61,11 @@ AST_MUTEX_DEFINE_STATIC(loglock);
static int pending_logger_reload = 0; static int pending_logger_reload = 0;
static int global_logmask = -1; static int global_logmask = -1;
static struct {
unsigned int queue_log:1;
unsigned int event_log:1;
} logfiles = { 1, 1 };
static struct msglist { static struct msglist {
char *msg; char *msg;
struct msglist *next; struct msglist *next;
...@@ -288,6 +293,13 @@ static void init_logger_chain(void) ...@@ -288,6 +293,13 @@ static void init_logger_chain(void)
strncpy(dateformat, s, sizeof(dateformat) - 1); strncpy(dateformat, s, sizeof(dateformat) - 1);
} else } else
strncpy(dateformat, "%b %e %T", sizeof(dateformat) - 1); strncpy(dateformat, "%b %e %T", sizeof(dateformat) - 1);
if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
logfiles.queue_log = ast_true(s);
}
if ((s = ast_variable_retrieve(cfg, "general", "event_log"))) {
logfiles.event_log = ast_true(s);
}
var = ast_variable_browse(cfg, "logfiles"); var = ast_variable_browse(cfg, "logfiles");
while(var) { while(var) {
chan = make_logchannel(var->name, var->value, var->lineno); chan = make_logchannel(var->name, var->value, var->lineno);
...@@ -332,7 +344,9 @@ static void queue_log_init(void) ...@@ -332,7 +344,9 @@ static void queue_log_init(void)
qlog = NULL; qlog = NULL;
} }
snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_LOG_DIR, "queue_log"); snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_LOG_DIR, "queue_log");
qlog = fopen(filename, "a"); if (logfiles.queue_log) {
qlog = fopen(filename, "a");
}
ast_mutex_unlock(&qloglock); ast_mutex_unlock(&qloglock);
if (reloaded) if (reloaded)
ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", ""); ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
...@@ -360,22 +374,24 @@ int reload_logger(int rotate) ...@@ -360,22 +374,24 @@ int reload_logger(int rotate)
mkdir((char *)ast_config_AST_LOG_DIR, 0755); mkdir((char *)ast_config_AST_LOG_DIR, 0755);
snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG); snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
if(rotate) { if (logfiles.event_log) {
for(x=0;;x++) { if (rotate) {
snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x); for (x=0;;x++) {
myf = fopen((char *)new, "r"); snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x);
if(myf) myf = fopen((char *)new, "r");
fclose(myf); if (myf)
else fclose(myf);
break; else
} break;
}
/* do it */ /* do it */
if (rename(old,new)) if (rename(old,new))
fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new); fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
} }
eventlog = fopen(old, "a"); eventlog = fopen(old, "a");
}
f = logchannels; f = logchannels;
while(f) { while(f) {
...@@ -406,16 +422,17 @@ int reload_logger(int rotate) ...@@ -406,16 +422,17 @@ int reload_logger(int rotate)
ast_mutex_unlock(&loglock); ast_mutex_unlock(&loglock);
queue_log_init(); queue_log_init();
if (eventlog) {
init_logger_chain();
ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
if (option_verbose)
ast_verbose("Asterisk Event Logger restarted\n");
return 0;
} else
ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
init_logger_chain(); init_logger_chain();
if (logfiles.event_log) {
if (eventlog) {
ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
if (option_verbose)
ast_verbose("Asterisk Event Logger restarted\n");
return 0;
} else
ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
}
pending_logger_reload = 0; pending_logger_reload = 0;
return -1; return -1;
} }
...@@ -487,21 +504,23 @@ int init_logger(void) ...@@ -487,21 +504,23 @@ int init_logger(void)
/* initialize queue logger */ /* initialize queue logger */
queue_log_init(); queue_log_init();
/* create the eventlog */
mkdir((char *)ast_config_AST_LOG_DIR, 0755);
snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
eventlog = fopen((char *)tmp, "a");
if (eventlog) {
init_logger_chain();
ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
if (option_verbose)
ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp);
return 0;
} else
ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
/* create log channels */ /* create log channels */
init_logger_chain(); init_logger_chain();
/* create the eventlog */
if (logfiles.event_log) {
mkdir((char *)ast_config_AST_LOG_DIR, 0755);
snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
eventlog = fopen((char *)tmp, "a");
if (eventlog) {
ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
if (option_verbose)
ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp);
return 0;
} else
ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
}
return -1; return -1;
} }
...@@ -576,7 +595,7 @@ void ast_log(int level, const char *file, int line, const char *function, const ...@@ -576,7 +595,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
localtime_r(&t, &tm); localtime_r(&t, &tm);
strftime(date, sizeof(date), dateformat, &tm); strftime(date, sizeof(date), dateformat, &tm);
if (level == __LOG_EVENT) { if (logfiles.event_log && level == __LOG_EVENT) {
va_start(ap, fmt); va_start(ap, fmt);
fprintf(eventlog, "%s asterisk[%d]: ", date, getpid()); fprintf(eventlog, "%s asterisk[%d]: ", date, getpid());
......
? .txt
? DDR.MOV
? FuzzyMath.mp3
? config-mark.c
? dont_panic.mp3
? gmon.out
? manpage.links
? manpage.refs
? markdiff.txt
? mydiff.txt
? newqueuelog
? resume-ken-long.pdf
? root.xwd
? rtp-timestamp.diff.txt
? stereo-1.0
? test.call
? test1.call
? test2.call
? test_js.txt
? tmp1.gsm
? tmp2.gsm
? tmp3.gsm
? tmp4.gsm
? apps/app_read_broken.c
? astman/.depend
? astman/astman
? cdr/cdr_csv2.c
? channels/chan_sip_broken.c
Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.57
diff -u -r1.57 logger.c
--- logger.c 11 Mar 2005 07:24:10 -0000 1.57
+++ logger.c 11 Mar 2005 08:27:54 -0000
@@ -61,6 +61,11 @@
static int pending_logger_reload = 0;
static int global_logmask = -1;
+static struct {
+ unsigned int queue_log:1;
+ unsigned int event_log:1;
+} logfiles = { 1, 1 };
+
static struct msglist {
char *msg;
struct msglist *next;
@@ -288,6 +293,13 @@
strncpy(dateformat, s, sizeof(dateformat) - 1);
} else
strncpy(dateformat, "%b %e %T", sizeof(dateformat) - 1);
+ if ((s = ast_variable_retrieve(cfg, "general", "queue_log"))) {
+ logfiles.queue_log = ast_true(s);
+ }
+ if ((s = ast_variable_retrieve(cfg, "general", "event_log"))) {
+ logfiles.event_log = ast_true(s);
+ }
+
var = ast_variable_browse(cfg, "logfiles");
while(var) {
chan = make_logchannel(var->name, var->value, var->lineno);
@@ -332,7 +344,9 @@
qlog = NULL;
}
snprintf(filename, sizeof(filename), "%s/%s", (char *)ast_config_AST_LOG_DIR, "queue_log");
- qlog = fopen(filename, "a");
+ if (logfiles.queue_log) {
+ qlog = fopen(filename, "a");
+ }
ast_mutex_unlock(&qloglock);
if (reloaded)
ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
@@ -360,22 +374,24 @@
mkdir((char *)ast_config_AST_LOG_DIR, 0755);
snprintf(old, sizeof(old), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
- if(rotate) {
- for(x=0;;x++) {
- snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x);
- myf = fopen((char *)new, "r");
- if(myf)
- fclose(myf);
- else
- break;
- }
+ if (logfiles.event_log) {
+ if (rotate) {
+ for (x=0;;x++) {
+ snprintf(new, sizeof(new), "%s/%s.%d", (char *)ast_config_AST_LOG_DIR, EVENTLOG,x);
+ myf = fopen((char *)new, "r");
+ if (myf)
+ fclose(myf);
+ else
+ break;
+ }
- /* do it */
- if (rename(old,new))
- fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
- }
+ /* do it */
+ if (rename(old,new))
+ fprintf(stderr, "Unable to rename file '%s' to '%s'\n", old, new);
+ }
- eventlog = fopen(old, "a");
+ eventlog = fopen(old, "a");
+ }
f = logchannels;
while(f) {
@@ -406,16 +422,17 @@
ast_mutex_unlock(&loglock);
queue_log_init();
-
- if (eventlog) {
- init_logger_chain();
- ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
- if (option_verbose)
- ast_verbose("Asterisk Event Logger restarted\n");
- return 0;
- } else
- ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
init_logger_chain();
+
+ if (logfiles.event_log) {
+ if (eventlog) {
+ ast_log(LOG_EVENT, "Restarted Asterisk Event Logger\n");
+ if (option_verbose)
+ ast_verbose("Asterisk Event Logger restarted\n");
+ return 0;
+ } else
+ ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
+ }
pending_logger_reload = 0;
return -1;
}
@@ -487,21 +504,23 @@
/* initialize queue logger */
queue_log_init();
- /* create the eventlog */
- mkdir((char *)ast_config_AST_LOG_DIR, 0755);
- snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
- eventlog = fopen((char *)tmp, "a");
- if (eventlog) {
- init_logger_chain();
- ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
- if (option_verbose)
- ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp);
- return 0;
- } else
- ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
-
/* create log channels */
init_logger_chain();
+
+ /* create the eventlog */
+ if (logfiles.event_log) {
+ mkdir((char *)ast_config_AST_LOG_DIR, 0755);
+ snprintf(tmp, sizeof(tmp), "%s/%s", (char *)ast_config_AST_LOG_DIR, EVENTLOG);
+ eventlog = fopen((char *)tmp, "a");
+ if (eventlog) {
+ ast_log(LOG_EVENT, "Started Asterisk Event Logger\n");
+ if (option_verbose)
+ ast_verbose("Asterisk Event Logger Started %s\n",(char *)tmp);
+ return 0;
+ } else
+ ast_log(LOG_ERROR, "Unable to create event log: %s\n", strerror(errno));
+ }
+
return -1;
}
@@ -576,7 +595,7 @@
localtime_r(&t, &tm);
strftime(date, sizeof(date), dateformat, &tm);
- if (level == __LOG_EVENT) {
+ if (logfiles.event_log && level == __LOG_EVENT) {
va_start(ap, fmt);
fprintf(eventlog, "%s asterisk[%d]: ", date, getpid());
Index: configs/logger.conf.sample
===================================================================
RCS file: /usr/cvsroot/asterisk/configs/logger.conf.sample,v
retrieving revision 1.9
diff -u -r1.9 logger.conf.sample
--- configs/logger.conf.sample 5 Sep 2004 03:48:05 -0000 1.9
+++ configs/logger.conf.sample 11 Mar 2005 08:27:55 -0000
@@ -13,6 +13,12 @@
; This appends the hostname to the name of the log files.
;appendhostname = yes
;
+; This determines whether or not we log queue events to a file (defaults to yes).
+;queue_log = no
+;
+; This determines whether or not we log generic events to a file (defaults to yes).
+;event_log = no
+;
;
; For each file, specify what to log.
;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment