trace: Hook lib/trace as a subsystem

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet
2020-01-09 11:41:23 -05:00
parent 6fc6cbd9b3
commit 70f031528d
7 changed files with 67 additions and 7 deletions
+3
View File
@@ -26,6 +26,7 @@
#include "lib/thread/thread_sys.h"
#include "lib/time/time_sys.h"
#include "lib/tls/tortls_sys.h"
#include "lib/trace/trace_sys.h"
#include "lib/wallclock/wallclock_sys.h"
#include "lib/evloop/evloop_sys.h"
@@ -47,6 +48,8 @@ const subsys_fns_t *tor_subsystems[] = {
&sys_logging,
&sys_threads,
&sys_tracing,
&sys_time,
&sys_crypto,
+1
View File
@@ -1,3 +1,4 @@
orconfig.h
lib/log/*.h
lib/trace/*.h
lib/subsys/*.h
+4 -2
View File
@@ -4,11 +4,13 @@ noinst_LIBRARIES += \
# ADD_C_FILE: INSERT SOURCES HERE.
LIBTOR_TRACE_A_SOURCES = \
src/lib/trace/trace.c
src/lib/trace/trace.c \
src/lib/trace/trace_sys.c
# ADD_C_FILE: INSERT HEADERS HERE.
TRACEHEADERS = \
src/lib/trace/trace.h \
src/lib/trace/trace.h \
src/lib/trace/trace_sys.h \
src/lib/trace/events.h
if USE_TRACING_INSTRUMENTATION_LOG_DEBUG
+7 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2020, The Tor Project, Inc. */
/* Copyright (c) 2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -15,3 +15,9 @@ void
tor_trace_init(void)
{
}
/** Free all the tracing library. */
void
tor_trace_free_all(void)
{
}
+5 -4
View File
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2020, The Tor Project, Inc. */
/* Copyright (c) 2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -6,9 +6,10 @@
* \brief Header for trace.c
**/
#ifndef TOR_TRACE_TRACE_H
#define TOR_TRACE_TRACE_H
#ifndef TOR_LIB_TRACE_TRACE_H
#define TOR_LIB_TRACE_TRACE_H
void tor_trace_init(void);
void tor_trace_free_all(void);
#endif /* !defined(TOR_TRACE_TRACE_H) */
#endif /* !defined(TOR_LIB_TRACE_TRACE_H) */
+33
View File
@@ -0,0 +1,33 @@
/* Copyright (c) 2018-2019, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* \file log_sys.c
* \brief Setup and tear down the tracing module.
**/
#include "lib/subsys/subsys.h"
#include "lib/trace/trace.h"
#include "lib/trace/trace_sys.h"
static int
subsys_tracing_initialize(void)
{
tor_trace_init();
return 0;
}
static void
subsys_tracing_shutdown(void)
{
tor_trace_free_all();
}
const subsys_fns_t sys_tracing = {
.name = "tracing",
.supported = true,
.level = -85,
.initialize = subsys_tracing_initialize,
.shutdown = subsys_tracing_shutdown,
};
+14
View File
@@ -0,0 +1,14 @@
/* Copyright (c) 2018-2019, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* \file log_sys.h
* \brief Declare subsystem object for the logging module.
**/
#ifndef TOR_TRACE_SYS_H
#define TOR_TRACE_SYS_H
extern const struct subsys_fns_t sys_tracing;
#endif /* !defined(TOR_TRACE_SYS_H) */