From befe46162b5264a2fd2948dfbc17b150ae4170a5 Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Thu, 26 Sep 2024 12:26:04 -0400 Subject: [PATCH] cdr_custom: Allow absolute filenames. 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. --- cdr/cdr_custom.c | 9 ++++++--- cel/cel_custom.c | 3 +-- configs/samples/cdr_custom.conf.sample | 5 +++++ configs/samples/cel_custom.conf.sample | 5 +++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c index 72a475c8c9..11cf6f49cb 100644 --- a/cdr/cdr_custom.c +++ b/cdr/cdr_custom.c @@ -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); diff --git a/cel/cel_custom.c b/cel/cel_custom.c index 468419c338..5f391e1f21 100644 --- a/cel/cel_custom.c +++ b/cel/cel_custom.c @@ -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); diff --git a/configs/samples/cdr_custom.conf.sample b/configs/samples/cdr_custom.conf.sample index bec9e3377f..b296e881b6 100644 --- a/configs/samples/cdr_custom.conf.sample +++ b/configs/samples/cdr_custom.conf.sample @@ -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)} ; diff --git a/configs/samples/cel_custom.conf.sample b/configs/samples/cel_custom.conf.sample index 126248acaf..3d5b978852 100644 --- a/configs/samples/cel_custom.conf.sample +++ b/configs/samples/cel_custom.conf.sample @@ -16,6 +16,11 @@ ; 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