Simplify aos/logging code
There are extra files and targets that we don't really need. Combine
them to simplify things.
Change-Id: Ife2901dd344df389f5e6f347d50f565627f47366
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/logging/BUILD b/aos/logging/BUILD
index ea5d15c..d9e4e94 100644
--- a/aos/logging/BUILD
+++ b/aos/logging/BUILD
@@ -8,6 +8,7 @@
"context.cc",
"implementations.cc",
"interface.cc",
+ "printf_formats.h",
],
hdrs = [
"context.h",
@@ -18,16 +19,11 @@
target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:public"],
deps = [
- ":printf_formats",
- ":sizes",
"//aos:die",
"//aos:macros",
"//aos/libc:aos_strerror",
- "//aos/stl_mutex",
"//aos/time",
- "//aos/type_traits",
"@com_github_google_glog//:glog",
- "@com_google_absl//absl/base",
],
)
@@ -44,14 +40,6 @@
],
)
-cc_library(
- name = "sizes",
- hdrs = [
- "sizes.h",
- ],
- target_compatible_with = ["@platforms//os:linux"],
-)
-
cc_test(
name = "implementations_test",
srcs = [
@@ -65,18 +53,6 @@
],
)
-cc_library(
- name = "printf_formats",
- hdrs = [
- "printf_formats.h",
- ],
- target_compatible_with = ["@platforms//os:linux"],
- visibility = ["//visibility:public"],
- deps = [
- "//aos:macros",
- ],
-)
-
flatbuffer_cc_library(
name = "log_message_fbs",
srcs = ["log_message.fbs"],
diff --git a/aos/logging/context.cc b/aos/logging/context.cc
index 0ffe01c..d1a6b03 100644
--- a/aos/logging/context.cc
+++ b/aos/logging/context.cc
@@ -20,7 +20,6 @@
#include "glog/logging.h"
-#include "aos/die.h"
#include "aos/logging/implementations.h"
namespace aos {
@@ -86,9 +85,8 @@
std::string_view Context::MyName() {
if (name_size == std::numeric_limits<size_t>::max()) {
::std::string my_name = GetMyName();
- if (my_name.size() + 1 > sizeof(Context::name)) {
- Die("logging: process/thread name '%s' is too long\n", my_name.c_str());
- }
+ CHECK_LE(my_name.size() + 1, sizeof(Context::name))
+ << ": process/thread name '" << my_name << "' is too long";
strcpy(name, my_name.c_str());
name_size = my_name.size();
}
diff --git a/aos/logging/context.h b/aos/logging/context.h
index 721b04b..bb53b99 100644
--- a/aos/logging/context.h
+++ b/aos/logging/context.h
@@ -10,11 +10,12 @@
#include <memory>
#include <string_view>
-#include "aos/logging/sizes.h"
-
namespace aos {
namespace logging {
+#define LOG_MESSAGE_LEN 512
+#define LOG_MESSAGE_NAME_LEN 100
+
class LogImplementation;
// This is where all of the code that is only used by actual LogImplementations
diff --git a/aos/logging/implementations.h b/aos/logging/implementations.h
index 36a4411..4e740f5 100644
--- a/aos/logging/implementations.h
+++ b/aos/logging/implementations.h
@@ -18,10 +18,8 @@
#include "aos/logging/context.h"
#include "aos/logging/interface.h"
#include "aos/logging/logging.h"
-#include "aos/logging/sizes.h"
#include "aos/macros.h"
#include "aos/time/time.h"
-#include "aos/type_traits/type_traits.h"
// This file has various concrete LogImplementations.
@@ -47,7 +45,6 @@
char name[LOG_MESSAGE_NAME_LEN];
char message[LOG_MESSAGE_LEN];
};
-static_assert(shm_ok<LogMessage>::value, "it's going in a queue");
// Returns left > right. LOG_UNKNOWN is most important.
static inline bool log_gt_important(log_level left, log_level right) {
diff --git a/aos/logging/sizes.h b/aos/logging/sizes.h
deleted file mode 100644
index d7cfd4e..0000000
--- a/aos/logging/sizes.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef AOS_LOGGING_SIZES_H_
-#define AOS_LOGGING_SIZES_H_
-
-// This file exists so C code and context.h can both get at these constants...
-
-#define LOG_MESSAGE_LEN 512
-#define LOG_MESSAGE_NAME_LEN 100
-
-#endif // AOS_LOGGING_SIZES_H_
diff --git a/frc971/control_loops/control_loop.h b/frc971/control_loops/control_loop.h
index 80b0bca..c02d094 100644
--- a/frc971/control_loops/control_loop.h
+++ b/frc971/control_loops/control_loop.h
@@ -6,7 +6,6 @@
#include "aos/events/event_loop.h"
#include "aos/time/time.h"
-#include "aos/type_traits/type_traits.h"
#include "aos/util/log_interval.h"
#include "frc971/input/joystick_state_generated.h"
#include "frc971/input/robot_state_generated.h"