aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asterisk/res_fax.h11
-rw-r--r--res/res_fax.c16
-rw-r--r--res/res_fax.exports.in1
-rw-r--r--res/res_fax_spandsp.c2
4 files changed, 29 insertions, 1 deletions
diff --git a/include/asterisk/res_fax.h b/include/asterisk/res_fax.h
index 9d83f6c2d..8e8cb3b92 100644
--- a/include/asterisk/res_fax.h
+++ b/include/asterisk/res_fax.h
@@ -256,4 +256,15 @@ unsigned int ast_fax_maxrate(void);
/*! \brief convert an ast_fax_state to a string */
const char *ast_fax_state_to_str(enum ast_fax_state state);
+/*!
+ * \brief Log message at FAX or recommended level
+ *
+ * The first four parameters can be represented with Asterisk's
+ * LOG_* levels. In other words, this function may be called
+ * like
+ *
+ * ast_fax_log(LOG_DEBUG, msg);
+ */
+void ast_fax_log(int level, const char *file, const int line, const char *function, const char *msg);
+
#endif
diff --git a/res/res_fax.c b/res/res_fax.c
index 04c426a0d..daccc7d0a 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -101,6 +101,8 @@ struct ast_fax_debug_info {
struct ast_dsp *dsp;
};
+static int fax_logger_level = -1;
+
/*! \brief maximum buckets for res_fax ao2 containers */
#define FAX_MAXBUCKETS 10
@@ -448,6 +450,15 @@ const char *ast_fax_state_to_str(enum ast_fax_state state)
}
}
+void ast_fax_log(int level, const char *file, const int line, const char *function, const char *msg)
+{
+ if (fax_logger_level != -1) {
+ ast_log_dynamic_level(fax_logger_level, "%s", msg);
+ } else {
+ ast_log(level, file, line, function, "%s", msg);
+ }
+}
+
/*! \brief convert a rate string to a rate */
static int fax_rate_str_to_int(const char *ratestr)
{
@@ -2195,6 +2206,10 @@ static int unload_module(void)
ast_log(LOG_WARNING, "failed to unregister '%s'\n", app_receivefax);
}
+ if (fax_logger_level != -1) {
+ ast_logger_unregister_level("FAX");
+ }
+
ao2_ref(faxregistry.container, -1);
return 0;
@@ -2231,6 +2246,7 @@ static int load_module(void)
}
ast_cli_register_multiple(fax_cli, ARRAY_LEN(fax_cli));
res = ast_custom_function_register(&acf_faxopt);
+ fax_logger_level = ast_logger_register_level("FAX");
return res;
}
diff --git a/res/res_fax.exports.in b/res/res_fax.exports.in
index 7cd569007..1b0e36469 100644
--- a/res/res_fax.exports.in
+++ b/res/res_fax.exports.in
@@ -6,6 +6,7 @@
LINKER_SYMBOL_PREFIXast_fax_minrate;
LINKER_SYMBOL_PREFIXast_fax_maxrate;
LINKER_SYMBOL_PREFIXast_fax_state_to_str;
+ LINKER_SYMBOL_PREFIXast_fax_log;
local:
*;
};
diff --git a/res/res_fax_spandsp.c b/res/res_fax_spandsp.c
index d29cf7902..3faf72267 100644
--- a/res/res_fax_spandsp.c
+++ b/res/res_fax_spandsp.c
@@ -366,7 +366,7 @@ static void spandsp_log(int level, const char *msg)
} else if (level == SPAN_LOG_WARNING) {
ast_log(LOG_WARNING, "%s", msg);
} else {
- ast_log(LOG_DEBUG, "%s", msg);
+ ast_fax_log(LOG_DEBUG, msg);
}
}