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.
18
Sean Bright 7 months ago
parent b29776a5b0
commit 9da3bdefef

@ -58,7 +58,6 @@
#include "asterisk/threadstorage.h" #include "asterisk/threadstorage.h"
#include "asterisk/strings.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); 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, format, "%s\n", var->value);
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_string_field_build(sink, filename, "%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
}
ast_mutex_init(&sink->lock); ast_mutex_init(&sink->lock);
AST_RWLIST_INSERT_TAIL(&sinks, sink, list); AST_RWLIST_INSERT_TAIL(&sinks, sink, list);

@ -43,7 +43,6 @@
#include "asterisk/threadstorage.h" #include "asterisk/threadstorage.h"
#include "asterisk/strings.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); AST_THREADSTORAGE(custom_buf);

@ -6,6 +6,11 @@
; in /var/log/asterisk). Depending on which mapping you uncomment, you may see ; in /var/log/asterisk). Depending on which mapping you uncomment, you may see
; Master.csv, Simple.csv, or both. ; 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] ;[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)} ;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)}
; ;

@ -16,6 +16,11 @@
; You can also create more than one template if desired. All logs will appear ; You can also create more than one template if desired. All logs will appear
; in the cel-custom directory under your Asterisk logs directory. ; 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 ; Within a mapping, use the CALLERID() and CHANNEL() functions to retrieve

Loading…
Cancel
Save