Module: kamailio
Branch: master
Commit: e5407c058f88fe06be2ee5da468ce2929748e31f
URL:
https://github.com/kamailio/kamailio/commit/e5407c058f88fe06be2ee5da468ce29…
Author: Xenofon Karamanos <22965395+xkaraman(a)users.noreply.github.com>
Committer: Xenofon Karamanos <22965395+xkaraman(a)users.noreply.github.com>
Date: 2024-07-18T16:37:15+03:00
sqlops: Add log_buf_size param for logging raw queries.
---
Modified: src/modules/sqlops/doc/sqlops_admin.xml
Modified: src/modules/sqlops/sql_api.c
Modified: src/modules/sqlops/sqlops.c
---
Diff:
https://github.com/kamailio/kamailio/commit/e5407c058f88fe06be2ee5da468ce29…
Patch:
https://github.com/kamailio/kamailio/commit/e5407c058f88fe06be2ee5da468ce29…
---
diff --git a/src/modules/sqlops/doc/sqlops_admin.xml
b/src/modules/sqlops/doc/sqlops_admin.xml
index aeaa54ef0ff..c26c63ebcd4 100644
--- a/src/modules/sqlops/doc/sqlops_admin.xml
+++ b/src/modules/sqlops/doc/sqlops_admin.xml
@@ -191,6 +191,28 @@ modparam("sqlops", "sqlres", "ra")
...
modparam("sqlops", "tr_buf_size", 4096)
...
+</programlisting>
+ </example>
+ </section>
+ <section id="sqlops.p.log_buf_size">
+ <title><varname>log_buf_size</varname> (int)</title>
+ <para>
+ The size of the buffer (characters) when logging raw SQL operations.
+ </para>
+ <para>
+ Note: When the buffer is smaller than the SQL operation, the operation is logged
truncated up to log_buf_size.
+ </para>
+ <para>
+ <emphasis>
+ Default value is 128.
+ </emphasis>
+ </para>
+ <example>
+ <title>Set <varname>log_buf_size</varname> parameter</title>
+ <programlisting format="linespecific">
+...
+modparam("sqlops", "log_buf_size", 4096)
+...
</programlisting>
</example>
</section>
@@ -607,4 +629,3 @@ xlog("Affected rows: $sqlrows(ca)\n");
</section>
</section>
</chapter>
-
diff --git a/src/modules/sqlops/sql_api.c b/src/modules/sqlops/sql_api.c
index b76edbd480e..255121dd87d 100644
--- a/src/modules/sqlops/sql_api.c
+++ b/src/modules/sqlops/sql_api.c
@@ -36,6 +36,7 @@
#include "sql_api.h"
extern int sqlops_results_maxsize;
+extern int sqlops_log_buf_size;
sql_con_t *_sql_con_root = NULL;
sql_result_t *_sql_result_root = NULL;
@@ -276,7 +277,9 @@ int sql_do_query(sql_con_t *con, str *query, sql_result_t *res)
}
if(con->dbf.raw_query(con->dbh, query, &db_res) != 0) {
LM_ERR("cannot do the query [%.*s]\n",
- (query->len > 64) ? 64 : query->len, query->s);
+ (query->len > sqlops_log_buf_size) ? sqlops_log_buf_size
+ : query->len,
+ query->s);
return -1;
}
diff --git a/src/modules/sqlops/sqlops.c b/src/modules/sqlops/sqlops.c
index 1b0859b1ca5..900dcacb371 100644
--- a/src/modules/sqlops/sqlops.c
+++ b/src/modules/sqlops/sqlops.c
@@ -77,6 +77,7 @@ static int sql_res_param(modparam_t type, void *val);
extern int sqlops_tr_buf_size;
int sqlops_results_maxsize = 32;
+int sqlops_log_buf_size = 128;
static int sqlops_connect_mode = 0;
@@ -106,6 +107,7 @@ static param_export_t params[] = {
{"sqlcon", PARAM_STRING | USE_FUNC_PARAM, (void *)sql_con_param},
{"sqlres", PARAM_STRING | USE_FUNC_PARAM, (void *)sql_res_param},
{"tr_buf_size", PARAM_INT, &sqlops_tr_buf_size},
+ {"log_buf_size", PARAM_INT, &sqlops_log_buf_size},
{"connect_mode", PARAM_INT, &sqlops_connect_mode},
{"results_maxsize", PARAM_INT, &sqlops_results_maxsize}, {0, 0, 0}};