summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorAlec L Davis <sivad.a@paradise.net.nz>2011-09-07 08:06:32 +0000
committerAlec L Davis <sivad.a@paradise.net.nz>2011-09-07 08:06:32 +0000
commit369ea4e7efdadf22c0918937e598e41a9c7d34ff (patch)
tree52376dd933258498da458280c35599497e05271c /main/logger.c
parent7b63ad3afbe00a3f578e1e6efd3335083aeff6ad (diff)
log Asterisk Version number, Build etc into each log file
Allow tracking of previous versions through log file records to be tracked. Each time log file is created or opened, log Asterisk Version, Buildinfo. etc. alecdavis (license 585) Tested by: alecdavis Review: https://reviewboard.asterisk.org/r/1409/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@334619 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/main/logger.c b/main/logger.c
index 209f374e6..0c8cdfc51 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -48,6 +48,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/syslog.h"
+#include "asterisk/buildinfo.h"
+#include "asterisk/ast_version.h"
#include <signal.h>
#include <time.h>
@@ -235,6 +237,9 @@ static struct logchannel *make_logchannel(const char *channel, const char *compo
{
struct logchannel *chan;
char *facility;
+ struct ast_tm tm;
+ struct timeval now = ast_tvnow();
+ char datestring[256];
if (ast_strlen_zero(channel) || !(chan = ast_calloc(1, sizeof(*chan) + strlen(components) + 1)))
return NULL;
@@ -283,6 +288,15 @@ static struct logchannel *make_logchannel(const char *channel, const char *compo
ast_console_puts_mutable("'\n", __LOG_ERROR);
ast_free(chan);
return NULL;
+ } else {
+ /* Create our date/time */
+ ast_localtime(&now, &tm, NULL);
+ ast_strftime(datestring, sizeof(datestring), dateformat, &tm);
+
+ fprintf(chan->fileptr, "[%s] Asterisk %s built by %s @ %s on a %s running %s on %s\n",
+ datestring, ast_get_version(), ast_build_user, ast_build_hostname,
+ ast_build_machine, ast_build_os, ast_build_date);
+ fflush(chan->fileptr);
}
chan->type = LOGTYPE_FILE;
}