diff --git a/asterisk.c b/asterisk.c index 69af7d4cb3fa1c6209e7a120475980da7dbc5a42..d9d962797eddead67a1a6186276c1d8f733848ff 100644 --- a/asterisk.c +++ b/asterisk.c @@ -2215,7 +2215,7 @@ static void ast_readconfig(void) /* verbose level (-v at startup) */ if (!strcasecmp(v->name, "verbose")) { option_verbose = atoi(v->value); - /* whether or not to force timestamping. (-T at startup) */ + /* whether or not to force timestamping in CLI verbose output. (-T at startup) */ } else if (!strcasecmp(v->name, "timestamp")) { ast_set2_flag(&ast_options, ast_true(v->value), AST_OPT_FLAG_TIMESTAMP); /* whether or not to support #exec in config files */ diff --git a/doc/asterisk-conf.txt b/doc/asterisk-conf.txt index a838bc561fe00a9a163a73d4b89d70a6ba336971..4ec2f26c50a6cbb5c13be205aa0f3075305888af 100644 --- a/doc/asterisk-conf.txt +++ b/doc/asterisk-conf.txt @@ -49,7 +49,7 @@ initcrypto = yes | no ; Initialize crypto at startup (-i) nocolor = yes | no ; Disable ANSI colors (-n) dumpcore = yes | no ; Dump core on failure (-g) quiet = yes | no ; Run quietly (-q) -timestamp = yes | no ; Force timestamping on log entries to console (-T) +timestamp = yes | no ; Force timestamping in CLI verbose output (-T) runuser = asterisk ; User to run asterisk as (-U) NOTE: will require changes to ; directory and device permisions rungroup = asterisk ; Group to run asterisk as (-G) diff --git a/include/asterisk/options.h b/include/asterisk/options.h index c0b8a433e75988fbd5f4e10f344a06b2a8af211f..3f7569ca1f07ef5f7901629e772a433877fef1d2 100644 --- a/include/asterisk/options.h +++ b/include/asterisk/options.h @@ -60,7 +60,7 @@ enum ast_option_flags { AST_OPT_FLAG_DUMP_CORE = (1 << 12), /*! Cache sound files */ AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13), - /*! Display timestamp in log messages */ + /*! Display timestamp in CLI verbose output */ AST_OPT_FLAG_TIMESTAMP = (1 << 14), /*! Override config */ AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15), diff --git a/logger.c b/logger.c index d7c70f0ec5e8f14ac27d25e5740734051d9c5e05..a4f7c8c1d7dea348b40f0b9be39dde310c8a1a9d 100644 --- a/logger.c +++ b/logger.c @@ -746,7 +746,7 @@ void ast_log(int level, const char *file, int line, const char *function, const if (level != __LOG_VERBOSE) { sprintf(linestr, "%d", line); - snprintf(buf, sizeof(buf), ast_opt_timestamp ? "[%s] %s[%ld]: %s:%s %s: " : "%s %s[%ld]: %s:%s %s: ", + snprintf(buf, sizeof(buf), "[%s] %s[%ld]: %s:%s %s: ", date, term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), (long)GETTID(), @@ -763,7 +763,7 @@ void ast_log(int level, const char *file, int line, const char *function, const /* File channels */ } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) { int res; - snprintf(buf, sizeof(buf), ast_opt_timestamp ? "[%s] %s[%ld]: " : "%s %s[%ld] %s: ", date, + snprintf(buf, sizeof(buf), "[%s] %s[%ld] %s: ", date, levels[level], (long)GETTID(), file); res = fprintf(chan->fileptr, buf); if (res <= 0 && buf[0] != '\0') { /* Error, no characters printed */ @@ -862,6 +862,8 @@ void ast_verbose(const char *fmt, ...) localtime_r(&t, &tm); strftime(date, sizeof(date), dateformat, &tm); datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1); + sprintf(datefmt, "[%s] %s", date, fmt); + fmt = datefmt; } /* this lock is also protecting against multiple threads