Browse Source

Extract the log_domain_t type to a lower-level header

This way, both err and log may depend on it.
Nick Mathewson 4 years ago
parent
commit
5fb070a14d

+ 1 - 0
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

+ 23 - 0
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

+ 2 - 1
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
+lib/version/*.h

+ 2 - 2
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);

+ 4 - 2
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);

+ 1 - 0
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

+ 1 - 3
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 {