summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app/main/main.c3
-rw-r--r--src/app/main/subsystem_list.c2
-rw-r--r--src/lib/log/.may_include1
-rw-r--r--src/lib/log/include.am2
-rw-r--r--src/lib/log/log.c1
-rw-r--r--src/lib/log/log_sys.c35
-rw-r--r--src/lib/log/log_sys.h14
7 files changed, 55 insertions, 3 deletions
diff --git a/src/app/main/main.c b/src/app/main/main.c
index 21a2832781..f44f3475dd 100644
--- a/src/app/main/main.c
+++ b/src/app/main/main.c
@@ -819,9 +819,7 @@ tor_free_all(int postfork)
/* Stuff in util.c and address.c*/
if (!postfork) {
- escaped(NULL);
esc_router_info(NULL);
- logs_free_all(); /* free log strings. do this last so logs keep working. */
}
}
@@ -1398,7 +1396,6 @@ tor_run_main(const tor_main_configuration_t *tor_cfg)
update_approx_time(time(NULL));
tor_compress_init();
- init_logging(0);
monotime_init();
int argc = tor_cfg->argc + tor_cfg->argc_owned;
diff --git a/src/app/main/subsystem_list.c b/src/app/main/subsystem_list.c
index c3b731ca39..4a2994ec49 100644
--- a/src/app/main/subsystem_list.c
+++ b/src/app/main/subsystem_list.c
@@ -11,6 +11,7 @@
#include "lib/err/torerr_sys.h"
#include "lib/process/winprocess_sys.h"
#include "lib/thread/thread_sys.h"
+#include "lib/log/log_sys.h"
#include <stddef.h>
@@ -21,6 +22,7 @@ const subsys_fns_t *tor_subsystems[] = {
&sys_winprocess,
&sys_torerr,
&sys_threads,
+ &sys_logging,
};
const unsigned n_tor_subsystems = ARRAY_LENGTH(tor_subsystems);
diff --git a/src/lib/log/.may_include b/src/lib/log/.may_include
index 7ca1863a52..11c87f0a0d 100644
--- a/src/lib/log/.may_include
+++ b/src/lib/log/.may_include
@@ -9,6 +9,7 @@ lib/lock/*.h
lib/log/*.h
lib/malloc/*.h
lib/string/*.h
+lib/subsys/*.h
lib/testsupport/*.h
lib/version/*.h
lib/wallclock/*.h
diff --git a/src/lib/log/include.am b/src/lib/log/include.am
index c6f404e269..9d3dbe3104 100644
--- a/src/lib/log/include.am
+++ b/src/lib/log/include.am
@@ -9,6 +9,7 @@ src_lib_libtor_log_a_SOURCES = \
src/lib/log/escape.c \
src/lib/log/ratelim.c \
src/lib/log/log.c \
+ src/lib/log/log_sys.c \
src/lib/log/util_bug.c
if WIN32
@@ -24,5 +25,6 @@ noinst_HEADERS += \
src/lib/log/escape.h \
src/lib/log/ratelim.h \
src/lib/log/log.h \
+ src/lib/log/log_sys.h \
src/lib/log/util_bug.h \
src/lib/log/win32err.h
diff --git a/src/lib/log/log.c b/src/lib/log/log.c
index bc7b36dcb9..46107fe848 100644
--- a/src/lib/log/log.c
+++ b/src/lib/log/log.c
@@ -32,6 +32,7 @@
#define LOG_PRIVATE
#include "lib/log/log.h"
+#include "lib/log/log_sys.h"
#include "lib/version/git_revision.h"
#include "lib/log/ratelim.h"
#include "lib/lock/compat_mutex.h"
diff --git a/src/lib/log/log_sys.c b/src/lib/log/log_sys.c
new file mode 100644
index 0000000000..94ec97fdc1
--- /dev/null
+++ b/src/lib/log/log_sys.c
@@ -0,0 +1,35 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file log_sys.c
+ * \brief Setup and tear down the logging module.
+ **/
+
+#include "orconfig.h"
+#include "lib/subsys/subsys.h"
+#include "lib/log/escape.h"
+#include "lib/log/log.h"
+#include "lib/log/log_sys.h"
+
+static int
+init_logging_subsys(void)
+{
+ init_logging(0);
+ return 0;
+}
+
+static void
+shutdown_logging_subsys(void)
+{
+ logs_free_all();
+ escaped(NULL);
+}
+
+const subsys_fns_t sys_logging = {
+ .name = "log",
+ .supported = true,
+ .level = -90,
+ .initialize = init_logging_subsys,
+ .shutdown = shutdown_logging_subsys,
+};
diff --git a/src/lib/log/log_sys.h b/src/lib/log/log_sys.h
new file mode 100644
index 0000000000..f7afbb279d
--- /dev/null
+++ b/src/lib/log/log_sys.h
@@ -0,0 +1,14 @@
+/* Copyright (c) 2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file log_sys.h
+ * \brief Declare subsystem object for the logging module.
+ **/
+
+#ifndef TOR_LOG_SYS_H
+#define TOR_LOG_SYS_H
+
+extern const struct subsys_fns_t sys_logging;
+
+#endif /* !defined(TOR_LOG_SYS_H) */