commit 5fb070a14da4802f11e84ed83143668502a227c4 Author: Nick Mathewson nickm@torproject.org Date: Fri Jul 19 10:17:22 2019 -0400
Extract the log_domain_t type to a lower-level header
This way, both err and log may depend on it. --- src/lib/defs/include.am | 1 + src/lib/defs/logging_types.h | 23 +++++++++++++++++++++++ src/lib/err/.may_include | 3 ++- src/lib/err/backtrace.c | 4 ++-- src/lib/err/backtrace.h | 6 ++++-- src/lib/log/.may_include | 1 + src/lib/log/log.h | 4 +--- 7 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/lib/defs/include.am b/src/lib/defs/include.am index dfddc92e5..84ee40377 100644 --- a/src/lib/defs/include.am +++ b/src/lib/defs/include.am @@ -3,5 +3,6 @@ noinst_HEADERS += \ src/lib/defs/dh_sizes.h \ src/lib/defs/digest_sizes.h \ + src/lib/defs/logging_types.h \ src/lib/defs/time.h \ src/lib/defs/x25519_sizes.h diff --git a/src/lib/defs/logging_types.h b/src/lib/defs/logging_types.h new file mode 100644 index 000000000..57db81800 --- /dev/null +++ b/src/lib/defs/logging_types.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2001, Matej Pfajfar. + * Copyright (c) 2001-2004, Roger Dingledine. + * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. + * Copyright (c) 2007-2019, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file logging_types.h + * + * \brief Global definition for types used by logging systems. + **/ + +#ifndef TOR_LOGGING_TYPES_H +#define TOR_LOGGING_TYPES_H + +/* We define this here so that it can be used both by backtrace.h and + * log.h. + */ + +/** Mask of zero or more log domains, OR'd together. */ +typedef uint64_t log_domain_mask_t; + +#endif diff --git a/src/lib/err/.may_include b/src/lib/err/.may_include index daa1b6e4c..314424545 100644 --- a/src/lib/err/.may_include +++ b/src/lib/err/.may_include @@ -1,5 +1,6 @@ orconfig.h lib/cc/*.h +lib/defs/*.h lib/err/*.h lib/subsys/*.h -lib/version/*.h \ No newline at end of file +lib/version/*.h diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c index f5fa7ec29..e6cbe3d32 100644 --- a/src/lib/err/backtrace.c +++ b/src/lib/err/backtrace.c @@ -115,7 +115,7 @@ clean_backtrace(void **stack, size_t depth, const ucontext_t *ctx) * that with a backtrace log. Send messages via the tor_log function at * logger". */ void -log_backtrace_impl(int severity, uint64_t domain, const char *msg, +log_backtrace_impl(int severity, log_domain_mask_t domain, const char *msg, tor_log_fn logger) { size_t depth; @@ -240,7 +240,7 @@ remove_bt_handler(void)
#ifdef NO_BACKTRACE_IMPL void -log_backtrace_impl(int severity, uint64_t domain, const char *msg, +log_backtrace_impl(int severity, log_domain_mask_t domain, const char *msg, tor_log_fn logger) { logger(severity, domain, "%s. (Stack trace not available)", msg); diff --git a/src/lib/err/backtrace.h b/src/lib/err/backtrace.h index ba3049ed1..dcd22cfef 100644 --- a/src/lib/err/backtrace.h +++ b/src/lib/err/backtrace.h @@ -13,11 +13,13 @@ #include "orconfig.h" #include "lib/cc/compat_compiler.h" #include "lib/cc/torint.h" +#include "lib/defs/logging_types.h"
-typedef void (*tor_log_fn)(int, uint64_t, const char *fmt, ...) +typedef void (*tor_log_fn)(int, log_domain_mask_t, const char *fmt, ...) CHECK_PRINTF(3,4);
-void log_backtrace_impl(int severity, uint64_t domain, const char *msg, +void log_backtrace_impl(int severity, log_domain_mask_t domain, + const char *msg, tor_log_fn logger); int configure_backtrace_handler(const char *tor_version); void clean_up_backtrace_handler(void); diff --git a/src/lib/log/.may_include b/src/lib/log/.may_include index 11c87f0a0..54d96324d 100644 --- a/src/lib/log/.may_include +++ b/src/lib/log/.may_include @@ -1,6 +1,7 @@ orconfig.h
lib/cc/*.h +lib/defs/*.h lib/smartlist_core/*.h lib/err/*.h lib/fdio/*.h diff --git a/src/lib/log/log.h b/src/lib/log/log.h index 301c7d571..c4a27782c 100644 --- a/src/lib/log/log.h +++ b/src/lib/log/log.h @@ -16,6 +16,7 @@ #include <stdarg.h> #include "lib/cc/torint.h" #include "lib/cc/compat_compiler.h" +#include "lib/defs/logging_types.h" #include "lib/testsupport/testsupport.h"
#ifdef HAVE_SYSLOG_H @@ -132,9 +133,6 @@ * would. Used as a flag, not a log domain. */ #define LD_NOFUNCNAME (UINT64_C(1)<<63)
-/** Mask of zero or more log domains, OR'd together. */ -typedef uint64_t log_domain_mask_t; - /** Configures which severities are logged for each logging domain for a given * log target. */ typedef struct log_severity_list_t {