summaryrefslogtreecommitdiffstats
path: root/src/rspamadm
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-10 20:53:22 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-10 21:12:13 +0000
commit3424122c9d082d53e8c437066d34cf602380a69c (patch)
tree85bd4b9503d3a903a55996c3c646f0c4c28195f8 /src/rspamadm
parent7630467d757c27fab944cda366e78ac82d45ff55 (diff)
downloadrspamd-3424122c9d082d53e8c437066d34cf602380a69c.tar.gz
rspamd-3424122c9d082d53e8c437066d34cf602380a69c.zip
[Rework] Logger: Fix issues found so far
Diffstat (limited to 'src/rspamadm')
-rw-r--r--src/rspamadm/configdump.c12
-rw-r--r--src/rspamadm/configtest.c19
-rw-r--r--src/rspamadm/rspamadm.c20
3 files changed, 9 insertions, 42 deletions
diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c
index 32e8ab3f1..de45d1cee 100644
--- a/src/rspamadm/configdump.c
+++ b/src/rspamadm/configdump.c
@@ -89,18 +89,6 @@ rspamadm_configdump_help (gboolean full_help, const struct rspamadm_command *cmd
static void
config_logger (rspamd_mempool_t *pool, gpointer ud)
{
- struct rspamd_main *rm = ud;
-
- rm->cfg->log_type = RSPAMD_LOG_CONSOLE;
- rm->cfg->log_level = G_LOG_LEVEL_CRITICAL;
-
- rspamd_set_logger (rm->cfg, g_quark_try_string ("main"), &rm->logger,
- rm->server_pool);
- if (rspamd_log_open_priv (rm->logger, rm->workers_uid, rm->workers_gid) ==
- -1) {
- fprintf (stderr, "Fatal error, cannot open logfile, exiting\n");
- exit (EXIT_FAILURE);
- }
}
static void
diff --git a/src/rspamadm/configtest.c b/src/rspamadm/configtest.c
index 1ebabe48b..bc7afd9d8 100644
--- a/src/rspamadm/configtest.c
+++ b/src/rspamadm/configtest.c
@@ -77,25 +77,6 @@ rspamadm_configtest_help (gboolean full_help, const struct rspamadm_command *cmd
static void
config_logger (rspamd_mempool_t *pool, gpointer ud)
{
- struct rspamd_main *rm = ud;
- GQuark configtest_quark = g_quark_from_static_string ("configtest");
-
- rm->cfg->log_type = RSPAMD_LOG_CONSOLE;
-
- if (quiet) {
- rm->cfg->log_level = G_LOG_LEVEL_CRITICAL;
- }
- else {
- rm->cfg->log_level = G_LOG_LEVEL_WARNING;
- }
-
- rspamd_set_logger (rm->cfg, configtest_quark, &rm->logger,
- rm->server_pool);
- if (rspamd_log_open_priv (rm->logger, rm->workers_uid, rm->workers_gid) ==
- -1) {
- fprintf (stderr, "Fatal error, cannot open logfile, exiting\n");
- exit (EXIT_FAILURE);
- }
}
static void
diff --git a/src/rspamadm/rspamadm.c b/src/rspamadm/rspamadm.c
index 775b505ee..1c1d6f52c 100644
--- a/src/rspamadm/rspamadm.c
+++ b/src/rspamadm/rspamadm.c
@@ -439,21 +439,19 @@ main (gint argc, gchar **argv, gchar **env)
}
/* Setup logger */
+ rspamd_main->logger = rspamd_log_open_emergency (rspamd_main->server_pool);
+
+ /* Setup logger */
if (verbose) {
- cfg->log_level = G_LOG_LEVEL_DEBUG;
- cfg->log_flags |= RSPAMD_LOG_FLAG_USEC|RSPAMD_LOG_FLAG_ENFORCED;
+ rspamd_log_set_log_level (rspamd_main->logger, G_LOG_LEVEL_DEBUG);
+ rspamd_log_set_log_flags (rspamd_main->logger,
+ RSPAMD_LOG_FLAG_USEC|RSPAMD_LOG_FLAG_ENFORCED|RSPAMD_LOG_FLAG_RSPAMADM);
}
else {
- cfg->log_level = G_LOG_LEVEL_MESSAGE;
+ rspamd_log_set_log_level (rspamd_main->logger, G_LOG_LEVEL_MESSAGE);
+ rspamd_log_set_log_flags (rspamd_main->logger,RSPAMD_LOG_FLAG_RSPAMADM);
}
- cfg->log_type = RSPAMD_LOG_CONSOLE;
- /* Avoid timestamps printing */
- cfg->log_flags |= RSPAMD_LOG_FLAG_RSPAMADM;
- rspamd_set_logger (cfg, process_quark, &rspamd_main->logger,
- rspamd_main->server_pool);
- (void) rspamd_log_open (rspamd_main->logger);
-
rspamd_main->event_loop = ev_default_loop (EVFLAG_SIGNALFD|EVBACKEND_ALL);
resolver = rspamd_dns_resolver_init (rspamd_main->logger,
@@ -616,7 +614,7 @@ end:
rspamd_dns_resolver_deinit (resolver);
REF_RELEASE (rspamd_main->cfg);
rspamd_http_context_free (rspamd_main->http_ctx);
- rspamd_log_close (rspamd_main->logger, TRUE);
+ rspamd_log_close (rspamd_main->logger);
rspamd_url_deinit ();
g_ptr_array_free (all_commands, TRUE);
ev_loop_destroy (rspamd_main->event_loop);