Index: manager.c =================================================================== RCS file: /usr/cvsroot/asterisk/manager.c,v retrieving revision 1.131 diff -u -r1.131 manager.c --- manager.c 26 Oct 2005 23:11:36 -0000 1.131 +++ manager.c 28 Oct 2005 17:15:23 -0000 @@ -78,6 +78,12 @@ static int asock = -1; static int displayconnects = 1; +static enum eventstamp { + EVSTAMP_NONE, + EVSTAMP_EPOCH, + EVSTAMP_HMS +} eventstamp = EVSTAMP_NONE; + static pthread_t t; AST_MUTEX_DEFINE_STATIC(sessionlock); static int block_sockets = 0; @@ -1481,6 +1487,8 @@ int manager_event(int category, char *event, char *fmt, ...) { struct mansession *s; + struct timeval now; + struct tm tm; char auth[80]; char tmp[4096] = ""; char *tmp_next = tmp; @@ -1498,6 +1506,15 @@ if (ast_strlen_zero(tmp)) { ast_build_string(&tmp_next, &tmp_left, "Event: %s\r\nPrivilege: %s\r\n", event, authority_to_str(category, auth, sizeof(auth))); + if (eventstamp == EVSTAMP_EPOCH) { + gettimeofday(&now, NULL); + ast_build_string(&tmp_next, &tmp_left, "Timestamp: %ld.%06lu\r\n", now.tv_sec, now.tv_usec); + } else if (eventstamp == EVSTAMP_HMS) { + char tmp2[80]; + gettimeofday(&now, NULL); + strftime(tmp2, sizeof(tmp2), "%F %T", localtime_r(&now.tv_sec, &tm)); + ast_build_string(&tmp_next, &tmp_left, "Timestamp: %s.%06lu\r\n", tmp2, now.tv_usec); + } va_start(ap, fmt); ast_build_string_va(&tmp_next, &tmp_left, fmt, ap); va_end(ap); @@ -1659,8 +1676,19 @@ if (val) enabled = ast_true(val); + eventstamp = EVSTAMP_NONE; + val = ast_variable_retrieve(cfg, "general", "eventstamp"); + if (val) { + if (!strcasecmp(val, "epoch")) + eventstamp = EVSTAMP_EPOCH; + else if (!strcasecmp(val, "hms")) + eventstamp = EVSTAMP_HMS; + else if (strcasecmp(val, "none")) + ast_log(LOG_WARNING, "Invalid eventstamp value '%s'\n", val); + } + val = ast_variable_retrieve(cfg, "general", "block-sockets"); - if(val) + if (val) block_sockets = ast_true(val); if ((val = ast_variable_retrieve(cfg, "general", "port"))) { Index: configs/manager.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/manager.conf.sample,v retrieving revision 1.7 diff -u -r1.7 manager.conf.sample --- configs/manager.conf.sample 4 Oct 2005 22:51:59 -0000 1.7 +++ configs/manager.conf.sample 28 Oct 2005 17:15:23 -0000 @@ -20,6 +20,9 @@ port = 5038 bindaddr = 0.0.0.0 ;displayconnects = yes +;eventstamp = epoch ; add timestamp to unsolicited events in ssssssssss.uuuuuu format +;eventstamp = hms ; add timestamp to unsolicited events in yyyy-mm-dd hh:mm:ss.uuuuuu format +;eventstamp = none ; (default) don't add timestamp ;[mark] ;secret = mysecret