aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-12-22 01:32:18 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-12-22 01:32:18 +0300
commite413f4ee9cd298baab701df31ab4c1cb91c7c4b6 (patch)
tree46858bef680c8a09b6d1d58a5ca7e3a8cec4e62d /src/lua
parenta079dac866ac4e166a8d6e40f978af74e8398583 (diff)
downloadrspamd-e413f4ee9cd298baab701df31ab4c1cb91c7c4b6.tar.gz
rspamd-e413f4ee9cd298baab701df31ab4c1cb91c7c4b6.zip
* Introduce new logging system:
- independent and customizeable buffering - line buffering - errors handling support - custom (ip based) debug - append function name automaticaly (based on __FUNCTION__) - add some logic to logs system
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/CMakeLists.txt1
-rw-r--r--src/lua/lua_classifier.c4
-rw-r--r--src/lua/lua_common.c16
-rw-r--r--src/lua/lua_config.c8
-rw-r--r--src/lua/lua_task.c6
5 files changed, 18 insertions, 17 deletions
diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt
index 298b81025..d0ac4f826 100644
--- a/src/lua/CMakeLists.txt
+++ b/src/lua/CMakeLists.txt
@@ -7,3 +7,4 @@ SET(LUASRC lua_common.c
ADD_LIBRARY(rspamd_lua STATIC ${LUASRC})
TARGET_LINK_LIBRARIES(rspamd_lua ${LUALIB})
+SET_TARGET_PROPERTIES(rspamd_lua PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c
index ed6cdee42..86378c5e5 100644
--- a/src/lua/lua_classifier.c
+++ b/src/lua/lua_classifier.c
@@ -90,7 +90,7 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task
*ptask = task;
if (lua_pcall (cd->L, 2, 1, 0) != 0) {
- msg_warn ("call_classifier_pre_callbacks: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
else {
if (lua_istable (cd->L, 1)) {
@@ -138,7 +138,7 @@ call_classifier_post_callbacks (struct classifier_config *ccf, struct worker_tas
lua_pushnumber (cd->L, out);
if (lua_pcall (cd->L, 3, 1, 0) != 0) {
- msg_warn ("call_classifier_pre_callbacks: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
else {
if (lua_isnumber (cd->L, 1)) {
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 1ad61aaf0..1d2f46c3a 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -214,7 +214,7 @@ init_lua_filters (struct config_file *cfg)
module = cur->data;
if (module->path) {
if (luaL_loadfile (L, module->path) != 0) {
- msg_info ("lua_init_filters: load of %s failed: %s", module->path, lua_tostring (L, -1));
+ msg_info ("load of %s failed: %s", module->path, lua_tostring (L, -1));
cur = g_list_next (cur);
continue;
}
@@ -226,7 +226,7 @@ init_lua_filters (struct config_file *cfg)
lua_setglobal (L, "rspamd_config");
/* do the call (1 arguments, 1 result) */
if (lua_pcall (L, 0, LUA_MULTRET, 0) != 0) {
- msg_info ("lua_init_filters: init of %s failed: %s", module->path, lua_tostring (L, -1));
+ msg_info ("init of %s failed: %s", module->path, lua_tostring (L, -1));
}
}
cur = g_list_next (cur);
@@ -247,12 +247,12 @@ lua_call_filter (const char *function, struct worker_task *task)
*ptask = task;
if (lua_pcall (L, 1, 1, 0) != 0) {
- msg_info ("lua_call_filter: call to %s failed", function);
+ msg_info ("call to %s failed", function);
}
/* retrieve result */
if (!lua_isnumber (L, -1)) {
- msg_info ("lua_call_filter: function %s must return a number", function);
+ msg_info ("function %s must return a number", function);
}
result = lua_tonumber (L, -1);
lua_pop (L, 1); /* pop returned value */
@@ -270,12 +270,12 @@ lua_call_chain_filter (const char *function, struct worker_task *task, int *mark
lua_pushnumber (L, marks[i]);
}
if (lua_pcall (L, number, 1, 0) != 0) {
- msg_info ("lua_init_filters: call to %s failed", function);
+ msg_info ("call to %s failed", function);
}
/* retrieve result */
if (!lua_isnumber (L, -1)) {
- msg_info ("lua_call_header_filter: function %s must return a number", function);
+ msg_info ("function %s must return a number", function);
}
result = lua_tonumber (L, -1);
lua_pop (L, 1); /* pop returned value */
@@ -303,12 +303,12 @@ lua_consolidation_callback (gpointer key, gpointer value, gpointer arg)
lua_pushstring (L, (const char *)key);
lua_pushnumber (L, s->score);
if (lua_pcall (L, 2, 1, 0) != 0) {
- msg_info ("lua_consolidation_callback: call to %s failed", data->func);
+ msg_info ("call to %s failed", data->func);
}
/* retrieve result */
if (!lua_isnumber (L, -1)) {
- msg_info ("lua_consolidation_callback: function %s must return a number", data->func);
+ msg_info ("function %s must return a number", data->func);
}
res = lua_tonumber (L, -1);
lua_pop (L, 1); /* pop returned value */
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index fa23134a9..bbbab4a53 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -301,7 +301,7 @@ lua_config_function_callback (struct worker_task *task, GList *args, void *user_
}
if (lua_pcall (cd->L, i, 1, 0) != 0) {
- msg_warn ("lua_metric_symbol_callback: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
else {
if (lua_isboolean (cd->L, 1)) {
@@ -345,7 +345,7 @@ lua_config_add_radix_map (lua_State *L)
r = g_malloc (sizeof (radix_tree_t *));
*r = radix_tree_create ();
if (!add_map (map_line, read_radix_list, fin_radix_list, (void **)r)) {
- msg_warn ("add_radix_map: invalid radix map %s", map_line);
+ msg_warn ("invalid radix map %s", map_line);
radix_tree_free (*r);
g_free (r);
lua_pushnil (L);
@@ -375,7 +375,7 @@ lua_config_add_hash_map (lua_State *L)
r = g_malloc (sizeof (GHashTable *));
*r = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
if (!add_map (map_line, read_host_list, fin_host_list, (void **)r)) {
- msg_warn ("add_radix_map: invalid hash map %s", map_line);
+ msg_warn ("invalid hash map %s", map_line);
g_hash_table_destroy (*r);
g_free (r);
lua_pushnil (L);
@@ -408,7 +408,7 @@ lua_metric_symbol_callback (struct worker_task *task, gpointer ud)
*ptask = task;
if (lua_pcall (cd->L, 1, 1, 0) != 0) {
- msg_warn ("lua_metric_symbol_callback: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
}
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index cfacf3f2f..dec415f9b 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -284,7 +284,7 @@ lua_dns_callback (int result, char type, int count, int ttl, void *addresses, vo
}
if (lua_pcall (cd->L, 4, 0, 0) != 0) {
- msg_info ("lua_dns_callback: call to %s failed: %s", cd->callback, lua_tostring (cd->L, -1));
+ msg_info ("call to %s failed: %s", cd->callback, lua_tostring (cd->L, -1));
}
cd->task->save.saved--;
@@ -310,7 +310,7 @@ lua_task_resolve_dns_a (lua_State * L)
cd->to_resolve = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 2));
cd->callback = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 3));
if (!cd->to_resolve || !cd->callback) {
- msg_info ("lua_task_resolve_dns_a: invalid parameters passed to function");
+ msg_info ("invalid parameters passed to function");
return 0;
}
if (evdns_resolve_ipv4 (cd->to_resolve, DNS_QUERY_NO_SEARCH, lua_dns_callback, (void *)cd) == 0) {
@@ -336,7 +336,7 @@ lua_task_resolve_dns_ptr (lua_State * L)
cd->callback = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 3));
ina = memory_pool_alloc (task->task_pool, sizeof (struct in_addr));
if (!cd->to_resolve || !cd->callback || !inet_aton (cd->to_resolve, ina)) {
- msg_info ("lua_task_resolve_dns_a: invalid parameters passed to function");
+ msg_info ("invalid parameters passed to function");
return 0;
}
if (evdns_resolve_reverse (ina, DNS_QUERY_NO_SEARCH, lua_dns_callback, (void *)cd) == 0) {