mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 07:18:15 +00:00
Add date formatting capability for logger (bug #1665)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2999 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3,6 +3,13 @@
|
|||||||
;
|
;
|
||||||
; In this file, you configure logging to files or to
|
; In this file, you configure logging to files or to
|
||||||
; the syslog system.
|
; the syslog system.
|
||||||
|
|
||||||
|
[general]
|
||||||
|
; Customize the display of debug message time stamps
|
||||||
|
; this example is the ISO 8601 date format (yyyy-mm-dd HH:MM:SS)
|
||||||
|
; see strftime(3) Linux manual for format specifiers
|
||||||
|
;dateformat=%F %T
|
||||||
|
|
||||||
;
|
;
|
||||||
; For each file, specify what to log.
|
; For each file, specify what to log.
|
||||||
;
|
;
|
||||||
|
|||||||
7
logger.c
7
logger.c
@@ -48,6 +48,7 @@ static int syslog_level_map[] = {
|
|||||||
|
|
||||||
#define MAX_MSG_QUEUE 200
|
#define MAX_MSG_QUEUE 200
|
||||||
|
|
||||||
|
static char dateformat[256] = "%b %e %T"; /* Original Asterisk Format */
|
||||||
static ast_mutex_t msglist_lock = AST_MUTEX_INITIALIZER;
|
static ast_mutex_t msglist_lock = AST_MUTEX_INITIALIZER;
|
||||||
static ast_mutex_t loglock = AST_MUTEX_INITIALIZER;
|
static ast_mutex_t loglock = AST_MUTEX_INITIALIZER;
|
||||||
static int pending_logger_reload = 0;
|
static int pending_logger_reload = 0;
|
||||||
@@ -186,6 +187,7 @@ static void init_logger_chain(void)
|
|||||||
struct logchannel *chan, *cur;
|
struct logchannel *chan, *cur;
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
struct ast_variable *var;
|
struct ast_variable *var;
|
||||||
|
char *s;
|
||||||
|
|
||||||
/* delete our list of log channels */
|
/* delete our list of log channels */
|
||||||
ast_mutex_lock(&loglock);
|
ast_mutex_lock(&loglock);
|
||||||
@@ -208,6 +210,9 @@ static void init_logger_chain(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ast_mutex_lock(&loglock);
|
ast_mutex_lock(&loglock);
|
||||||
|
if ((s = ast_variable_retrieve(cfg, "general", "dateformat"))) {
|
||||||
|
(void)strncpy(dateformat,s,sizeof(dateformat));
|
||||||
|
}
|
||||||
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);
|
||||||
@@ -466,7 +471,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||||||
|
|
||||||
time(&t);
|
time(&t);
|
||||||
localtime_r(&t, &tm);
|
localtime_r(&t, &tm);
|
||||||
strftime(date, sizeof(date), "%b %e %T", &tm);
|
strftime(date, sizeof(date), dateformat, &tm);
|
||||||
|
|
||||||
|
|
||||||
if (level == __LOG_EVENT) {
|
if (level == __LOG_EVENT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user