]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
cdr_custom: Allow absolute filenames.
authorSean Bright <sean@seanbright.com>
Thu, 26 Sep 2024 16:26:04 +0000 (12:26 -0400)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 14 Nov 2024 20:01:34 +0000 (20:01 +0000)
A follow up to #893 that brings the same functionality to
cdr_custom. Also update the sample configuration files to note support
for absolute paths.

(cherry picked from commit 084c04f7113de3971253cde4e7da2b4ce2541656)

cdr/cdr_custom.c
cel/cel_custom.c
configs/samples/cdr_custom.conf.sample
configs/samples/cel_custom.conf.sample

index 72a475c8c9e88056d611d0493e25559d87c63d29..11cf6f49cb01b72b9d9de19552ef5ee4b5a73fb2 100644 (file)
@@ -58,8 +58,7 @@
 #include "asterisk/threadstorage.h"
 #include "asterisk/strings.h"
 
-#define CUSTOM_LOG_DIR "/cdr_custom"
-#define CONFIG         "cdr_custom.conf"
+#define CONFIG "cdr_custom.conf"
 
 AST_THREADSTORAGE(custom_buf);
 
@@ -112,7 +111,11 @@ static int load_config(void)
                        }
 
                        ast_string_field_build(sink, format, "%s\n", var->value);
-                       ast_string_field_build(sink, filename, "%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
+                       if (var->name[0] == '/') {
+                               ast_string_field_build(sink, filename, "%s", var->name);
+                       } else {
+                               ast_string_field_build(sink, filename, "%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
+                       }
                        ast_mutex_init(&sink->lock);
 
                        AST_RWLIST_INSERT_TAIL(&sinks, sink, list);
index 468419c3383ac0690e02e0775f3846c4af9a7f1d..5f391e1f2139f44a8a0946f81eb7e4203c2031d3 100644 (file)
@@ -43,8 +43,7 @@
 #include "asterisk/threadstorage.h"
 #include "asterisk/strings.h"
 
-#define CUSTOM_LOG_DIR "/cel_custom"
-#define CONFIG         "cel_custom.conf"
+#define CONFIG "cel_custom.conf"
 
 AST_THREADSTORAGE(custom_buf);
 
index bec9e3377f06b823070502fb63fddc3485498f1f..b296e881b67bfeae3f03e010ced36a2571dd4eb9 100644 (file)
@@ -6,6 +6,11 @@
 ; in /var/log/asterisk).  Depending on which mapping you uncomment, you may see
 ; Master.csv, Simple.csv, or both.
 ;
+; Alternatively, you can also specify the location of your CSV file using an
+; absolute path, e.g.:
+;
+;     /srv/pbx/cdr/Master.csv => ${CSV_QUOTE(${CDR(clid)})},...
+;
 ;[mappings]
 ;Master.csv => ${CSV_QUOTE(${CDR(clid)})},${CSV_QUOTE(${CDR(src)})},${CSV_QUOTE(${CDR(dst)})},${CSV_QUOTE(${CDR(dcontext)})},${CSV_QUOTE(${CDR(channel)})},${CSV_QUOTE(${CDR(dstchannel)})},${CSV_QUOTE(${CDR(lastapp)})},${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(start)})},${CSV_QUOTE(${CDR(answer)})},${CSV_QUOTE(${CDR(end)})},${CSV_QUOTE(${CDR(duration)})},${CSV_QUOTE(${CDR(billsec)})},${CSV_QUOTE(${CDR(disposition)})},${CSV_QUOTE(${CDR(amaflags)})},${CSV_QUOTE(${CDR(accountcode)})},${CSV_QUOTE(${CDR(uniqueid)})},${CSV_QUOTE(${CDR(userfield)})},${CDR(sequence)}
 ;
index 126248acaff03500c95a20be3f069cff8ab1cfea..3d5b97885213c54bddc44c5f35199c0ce4cb35ab 100644 (file)
 ; You can also create more than one template if desired.  All logs will appear
 ; in the cel-custom directory under your Asterisk logs directory.
 ;
+; Alternatively, you can also specify the location of your CSV file using an
+; absolute path, e.g.:
+;
+;     /srv/pbx/cel/Master.csv => ${CSV_QUOTE(${eventtype})},...
+;
 
 ;
 ; Within a mapping, use the CALLERID() and CHANNEL() functions to retrieve