Remove corking from AOS_LOG
Nobody has used it, and we are pushing more things towards glog or
flatbuffers.
Change-Id: Idbbbc5d85987e0d643d4c61958b5ffd81db0eb42
diff --git a/aos/logging/context.cc b/aos/logging/context.cc
index c6f1063..446e0df 100644
--- a/aos/logging/context.cc
+++ b/aos/logging/context.cc
@@ -73,9 +73,7 @@
} // namespace
-Context::Context() : implementation(GetImplementation()), sequence(0) {
- cork_data.Reset();
-}
+Context::Context() : implementation(GetImplementation()), sequence(0) {}
// Used in aos/linux_code/init.cc when a thread's name is changed.
void ReloadThreadName() {
diff --git a/aos/logging/context.h b/aos/logging/context.h
index 2e8250e..43ac54f 100644
--- a/aos/logging/context.h
+++ b/aos/logging/context.h
@@ -57,25 +57,6 @@
// The sequence value to send out with the next message.
uint16_t sequence;
-
- // Contains all of the information related to implementing LOG_CORK and
- // LOG_UNCORK.
- struct {
- char message[LOG_MESSAGE_LEN];
- int line_min, line_max;
- // Sets the data up to record a new series of corked logs.
- void Reset() {
- message[0] = '\0'; // make strlen of it 0
- line_min = INT_MAX;
- line_max = -1;
- function = NULL;
- }
- // The function that the calls are in.
- // REMEMBER: While the compiler/linker will probably optimize all of the
- // identical strings to point to the same data, it might not, so using == to
- // compare this with another value is a bad idea.
- const char *function;
- } cork_data;
};
} // namespace internal
diff --git a/aos/logging/implementations_test.cc b/aos/logging/implementations_test.cc
index 84a1bed..f6cdc6f 100644
--- a/aos/logging/implementations_test.cc
+++ b/aos/logging/implementations_test.cc
@@ -118,24 +118,6 @@
AOS_LOG(WARNING, "test log 4\n");
EXPECT_TRUE(WasAnythingLogged());
}
-TEST_F(LoggingTest, Cork) {
- static const int begin_line = __LINE__;
- AOS_LOG_CORK("first part ");
- AOS_LOG_CORK("second part (=%d) ", 19);
- EXPECT_FALSE(WasAnythingLogged());
- AOS_LOG_CORK("third part ");
- static const int end_line = __LINE__;
- AOS_LOG_UNCORK(WARNING, "last part %d\n", 5);
- std::stringstream expected;
- expected << "implementations_test.cc: ";
- expected << (begin_line + 1);
- expected << "-";
- expected << (end_line + 1);
- expected << ": ";
- expected << __func__;
- expected << ": first part second part (=19) third part last part 5\n";
- EXPECT_TRUE(WasLogged(WARNING, expected.str()));
-}
TEST_F(LoggingDeathTest, Fatal) {
ASSERT_EXIT(AOS_LOG(FATAL, "this should crash it\n"),
@@ -154,9 +136,6 @@
EXPECT_TRUE(WasLogged(INFO, "test log %1 %d\n"));
AOS_LOG_DYNAMIC(WARNING, "test log %%2 %%f\n");
EXPECT_TRUE(WasLogged(WARNING, "test log %2 %f\n"));
- AOS_LOG_CORK("log 3 part %%1 %%d ");
- AOS_LOG_UNCORK(DEBUG, "log 3 part %%2 %%f\n");
- EXPECT_TRUE(WasLogged(DEBUG, "log 3 part %1 %d log 3 part %2 %f\n"));
}
TEST_F(LoggingTest, Timing) {
diff --git a/aos/logging/interface.cc b/aos/logging/interface.cc
index 6a201aa..b2f7b75 100644
--- a/aos/logging/interface.cc
+++ b/aos/logging/interface.cc
@@ -66,40 +66,6 @@
LogImplementation::DoVLog(level, format, ap);
}
-void VCork(int line, const char *function, const char *format, va_list ap) {
- Context *context = Context::Get();
-
- const size_t message_length = strlen(context->cork_data.message);
- if (line > context->cork_data.line_max) context->cork_data.line_max = line;
- if (line < context->cork_data.line_min) context->cork_data.line_min = line;
-
- if (context->cork_data.function == NULL) {
- context->cork_data.function = function;
- } else {
- if (strcmp(context->cork_data.function, function) != 0) {
- AOS_LOG(FATAL,
- "started corking data in function %s but then moved to %s\n",
- context->cork_data.function, function);
- }
- }
-
- internal::ExecuteFormat(context->cork_data.message + message_length,
- sizeof(context->cork_data.message) - message_length,
- format, ap);
-}
-
-void VUnCork(int line, const char *function, log_level level, const char *file,
- const char *format, va_list ap) {
- Context *context = Context::Get();
-
- VCork(line, function, format, ap);
-
- log_do(level, "%s: %d-%d: %s: %s", file, context->cork_data.line_min,
- context->cork_data.line_max, function, context->cork_data.message);
-
- context->cork_data.Reset();
-}
-
} // namespace logging
} // namespace aos
@@ -109,18 +75,3 @@
aos::logging::VLog(level, format, ap);
va_end(ap);
}
-
-void log_cork(int line, const char *function, const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- aos::logging::VCork(line, function, format, ap);
- va_end(ap);
-}
-
-void log_uncork(int line, const char *function, log_level level,
- const char *file, const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- aos::logging::VUnCork(line, function, level, file, format, ap);
- va_end(ap);
-}
diff --git a/aos/logging/logging.h b/aos/logging/logging.h
index bd9b103..28e2ab5 100644
--- a/aos/logging/logging.h
+++ b/aos/logging/logging.h
@@ -42,13 +42,6 @@
void log_do(log_level level, const char *format, ...)
__attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 3)));
-void log_cork(int line, const char *function, const char *format, ...)
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 4)));
-// Implements the uncork logging call.
-void log_uncork(int line, const char *function, log_level level,
- const char *file, const char *format, ...)
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 5, 6)));
-
#ifdef __cplusplus
}
#endif
@@ -101,21 +94,6 @@
} \
} while (0)
-// Allows "bottling up" multiple log fragments which can then all be logged in
-// one message with LOG_UNCORK.
-// Calls from a given thread/task will be grouped together.
-#define AOS_LOG_CORK(format, args...) \
- do { \
- log_cork(__LINE__, LOG_CURRENT_FUNCTION, format, ##args); \
- } while (0)
-// Actually logs all of the saved up log fragments (including format and args on
-// the end).
-#define AOS_LOG_UNCORK(level, format, args...) \
- do { \
- log_uncork(__LINE__, LOG_CURRENT_FUNCTION, level, LOG_SOURCENAME, format, \
- ##args); \
- } while (0)
-
#ifdef __cplusplus
}
#endif
@@ -162,6 +140,9 @@
// controlled by NDEBUG, so the check will be executed regardless of
// compilation mode. Therefore, it is safe to do things like:
// CHECK(fp->Write(x) == 4)
+// TODO(austin): We want to be pushing people to glog instead of AOS_CHECK here.
+// You are crashing anyways. If we want glog to tee to AOS_LOG as well, we'll
+// implement that through that path.
#define AOS_CHECK(condition) \
if (__builtin_expect(!(condition), 0)) { \
AOS_LOG(FATAL, "CHECK(%s) failed\n", #condition); \