cdr/cdr_csv.c: Set file name for csv master to the module when (re)loaded.

Compute the location for the csv master file when the module is
loaded or reload.  Before it was calculated every time a log
entry was written.

Change-Id: I3ed9f6a8f965308099db70b71128f43d4d3f5585
changes/04/404/5
Rodrigo Ramírez Norambuena 10 years ago committed by Richard Mudgett
parent 009b44172d
commit 2cd40c2bd7

@ -60,6 +60,7 @@ static int loguserfield = 0;
static int loaded = 0;
static int newcdrcolumns = 0;
static const char config[] = "cdr.conf";
static char file_csv_master[PATH_MAX];
/* #define CSV_LOGUNIQUEID 1 */
/* #define CSV_LOGUSERFIELD 1 */
@ -120,6 +121,12 @@ static int load_config(int reload)
return 0;
}
/* compute the location of the csv master file */
ast_mutex_lock(&f_lock);
snprintf(file_csv_master, sizeof(file_csv_master),
"%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
ast_mutex_unlock(&f_lock);
for (; v; v = v->next) {
if (!strcasecmp(v->name, "usegmtime")) {
usegmtime = ast_true(v->value);
@ -293,16 +300,14 @@ static int csv_log(struct ast_cdr *cdr)
{
/* Make sure we have a big enough buf */
char buf[1024];
char csvmaster[PATH_MAX];
snprintf(csvmaster, sizeof(csvmaster),"%s/%s/%s", ast_config_AST_LOG_DIR, CSV_LOG_DIR, CSV_MASTER);
if (build_csv_record(buf, sizeof(buf), cdr)) {
ast_log(LOG_WARNING, "Unable to create CSV record in %d bytes. CDR not recorded!\n", (int)sizeof(buf));
return 0;
}
ast_mutex_lock(&f_lock);
if (writefile(buf, csvmaster))
ast_log(LOG_WARNING, "Unable to write CSV record to master '%s' : %s\n", csvmaster, strerror(errno));
if (writefile(buf, file_csv_master))
ast_log(LOG_WARNING, "Unable to write CSV record to master '%s' : %s\n", file_csv_master, strerror(errno));
if (accountlogs && !ast_strlen_zero(cdr->accountcode)) {
if (writefile_account(buf, cdr->accountcode))

Loading…
Cancel
Save