]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Make absolute paths for logger channels work properly
authorKevin P. Fleming <kpfleming@digium.com>
Fri, 8 May 2009 14:03:28 +0000 (14:03 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Fri, 8 May 2009 14:03:28 +0000 (14:03 +0000)
(Note: This is not a new feature, it was previously undocumented and broken.)

The Asterisk logger has a feature to support absolute pathnames for logger channels, but the code implementing the feature was broken. This has been fixed, and the absolute path feature is now documented in the sample logger.conf.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@193193 65c4cc65-6c06-0410-ace0-fbb531ad65f3

configs/logger.conf.sample
main/logger.c

index f2ff0ea7eb9907d676c05b1d2a6fca7a85be43d5..c28c302a82776f8dfecb5b8894654f145826474e 100644 (file)
 ;
 ; Special filename "console" represents the system console
 ;
+; Filenams can either be relative to the standard Asterisk log directory
+; (see 'astlogdir' in asterisk.conf), or absolute paths that begin with
+; '/'.
+;
 ; We highly recommend that you DO NOT turn on debug mode if you are simply
 ; running a production system.  Debug mode turns on a LOT of extra messages,
 ; most of which you are unlikely to understand without an understanding of
index 0d1ef4b71f704865ccbf51af897945a36a45fd86..e1913eed30a9490c1ca9846685cf49131429aedb 100644 (file)
@@ -257,18 +257,12 @@ static struct logchannel *make_logchannel(char *channel, char *components, int l
                snprintf(chan->filename, sizeof(chan->filename), "%s", channel);
                openlog("asterisk", LOG_PID, chan->facility);
        } else {
-               if (channel[0] == '/') {
-                       if(!ast_strlen_zero(hostname)) { 
-                               snprintf(chan->filename, sizeof(chan->filename) - 1,"%s.%s", channel, hostname);
-                       } else {
-                               ast_copy_string(chan->filename, channel, sizeof(chan->filename));
-                       }
-               }                 
-               
-               if(!ast_strlen_zero(hostname)) {
-                       snprintf(chan->filename, sizeof(chan->filename), "%s/%s.%s",(char *)ast_config_AST_LOG_DIR, channel, hostname);
+               if (!ast_strlen_zero(hostname)) {
+                       snprintf(chan->filename, sizeof(chan->filename), "%s/%s.%s",
+                                channel[0] != '/' ? ast_config_AST_LOG_DIR : "", channel, hostname);
                } else {
-                       snprintf(chan->filename, sizeof(chan->filename), "%s/%s", (char *)ast_config_AST_LOG_DIR, channel);
+                       snprintf(chan->filename, sizeof(chan->filename), "%s/%s",
+                                channel[0] != '/' ? ast_config_AST_LOG_DIR : "", channel);
                }
                chan->fileptr = fopen(chan->filename, "a");
                if (!chan->fileptr) {