aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Jansen <jansene@google.com>2023-10-31 22:53:41 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-10-31 22:53:41 +0000
commit8bc35621cfe488353f7d5686e21cdead7fad8ae9 (patch)
tree7dae0c18ba6bc0ab0ff2f89361c0a01aa8e06469
parent2f01d2ce1dbb7896a56eb1bf3e910c74c2bbb69c (diff)
parent5c6bb90a64cf76ad34be04196e2f528226c75aa5 (diff)
downloadaemu-8bc35621cfe488353f7d5686e21cdead7fad8ae9.tar.gz
Make the logging library shared am: 5c6bb90a64
Original change: https://android-review.googlesource.com/c/platform/hardware/google/aemu/+/2808323 Change-Id: Ia628a2e492b111dba4bf4851d3658a34616ec0eb Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--base/include/aemu/base/logging/CLog.h43
-rw-r--r--base/include/aemu/base/logging/Log.h42
-rw-r--r--base/include/aemu/base/logging/LogSeverity.h14
-rw-r--r--base/include/aemu/base/logging/LogTags.h17
4 files changed, 70 insertions, 46 deletions
diff --git a/base/include/aemu/base/logging/CLog.h b/base/include/aemu/base/logging/CLog.h
index 6417c98..9a7959a 100644
--- a/base/include/aemu/base/logging/CLog.h
+++ b/base/include/aemu/base/logging/CLog.h
@@ -19,8 +19,19 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
+
#include "aemu/base/logging/LogSeverity.h"
+#ifdef _MSC_VER
+#ifdef LOGGING_API_SHARED
+#define LOGGING_API __declspec(dllexport)
+#else
+#define LOGGING_API __declspec(dllimport)
+#endif
+#else
+#define LOGGING_API
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -32,18 +43,21 @@ typedef enum {
kLogEnableVerbose = 1 << 3,
} LoggingFlags;
-
// Enable/disable verbose logs from the base/* family.
-extern void base_enable_verbose_logs();
-extern void base_disable_verbose_logs();
+LOGGING_API void base_enable_verbose_logs();
+LOGGING_API void base_disable_verbose_logs();
+
+LOGGING_API void verbose_enable(uint64_t tag);
+LOGGING_API void verbose_disable(uint64_t tag);
+LOGGING_API bool verbose_check(uint64_t tag);
+LOGGING_API bool verbose_check_any();
+LOGGING_API void set_verbosity_mask(uint64_t mask);
+LOGGING_API uint64_t get_verbosity_mask();
// Configure the logging framework.
-extern void base_configure_logs(LoggingFlags flags);
-extern void __emu_log_print(LogSeverity prio,
- const char* file,
- int line,
- const char* fmt,
- ...);
+LOGGING_API void base_configure_logs(LoggingFlags flags);
+LOGGING_API void __emu_log_print(LogSeverity prio, const char* file, int line, const char* fmt,
+ ...);
#ifndef EMULOG
#define EMULOG(priority, fmt, ...) \
@@ -51,21 +65,21 @@ extern void __emu_log_print(LogSeverity prio,
#endif
// Logging support.
-#define dprint(fmt, ...) \
- if (EMULATOR_LOG_DEBUG >= android_log_severity) { \
+#define dprint(fmt, ...) \
+ if (EMULATOR_LOG_DEBUG >= getMinLogLevel()) { \
EMULOG(EMULATOR_LOG_DEBUG, fmt, ##__VA_ARGS__) \
}
#define dinfo(fmt, ...) \
- if (EMULATOR_LOG_INFO >= android_log_severity) { \
+ if (EMULATOR_LOG_INFO >= getMinLogLevel()) { \
EMULOG(EMULATOR_LOG_INFO, fmt, ##__VA_ARGS__) \
}
#define dwarning(fmt, ...) \
- if (EMULATOR_LOG_WARNING >= android_log_severity) { \
+ if (EMULATOR_LOG_WARNING >= getMinLogLevel()) { \
EMULOG(EMULATOR_LOG_WARNING, fmt, ##__VA_ARGS__) \
}
#define derror(fmt, ...) \
- if (EMULATOR_LOG_ERROR >= android_log_severity) { \
+ if (EMULATOR_LOG_ERROR >= getMinLogLevel()) { \
EMULOG(EMULATOR_LOG_ERROR, fmt, ##__VA_ARGS__) \
}
#define dfatal(fmt, ...) EMULOG(EMULATOR_LOG_FATAL, fmt, ##__VA_ARGS__)
@@ -73,4 +87,3 @@ extern void __emu_log_print(LogSeverity prio,
#ifdef __cplusplus
}
#endif
-
diff --git a/base/include/aemu/base/logging/Log.h b/base/include/aemu/base/logging/Log.h
index dff3d02..7a1b159 100644
--- a/base/include/aemu/base/logging/Log.h
+++ b/base/include/aemu/base/logging/Log.h
@@ -23,16 +23,22 @@
#include "aemu/base/logging/LogSeverity.h" // for LogSeverity, EMULATOR_...
+#ifdef _MSC_VER
+# ifdef LOGGING_API_SHARED
+# define LOGGING_API __declspec(dllexport)
+# else
+# define LOGGING_API __declspec(dllimport)
+#endif
+#else
+# define LOGGING_API
+#endif
+
namespace android {
namespace base {
-// Returns the minimal log level.
-::LogSeverity getMinLogLevel();
-void setMinLogLevel(::LogSeverity level);
-
class LogFormatter;
-void setLogFormatter(LogFormatter* fmt);
+LOGGING_API void setLogFormatter(LogFormatter* fmt);
// Convert a log level name (e.g. 'INFO') into the equivalent
// ::android::base LOG_<name> constant.
@@ -47,7 +53,7 @@ void setLogFormatter(LogFormatter* fmt);
// }
//
#define LOG_IS_ON(severity) \
- (LOG_SEVERITY_FROM(severity) >= ::android::base::getMinLogLevel())
+ (LOG_SEVERITY_FROM(severity) >= getMinLogLevel())
// For performance reasons, it's important to avoid constructing a
// LogMessage instance every time a LOG() or CHECK() statement is
@@ -205,11 +211,11 @@ void setLogFormatter(LogFormatter* fmt);
#endif
// A function that returns true iff DCHECK() should actually do any checking.
-bool dcheckIsEnabled();
+LOGGING_API bool dcheckIsEnabled();
// Change the DCHECK() level to either false or true. Should only be called
// early, e.g. after parsing command-line arguments. Returns previous value.
-bool setDcheckLevel(bool enabled);
+LOGGING_API bool setDcheckLevel(bool enabled);
// DLOG() is like LOG() for debug builds, and doesn't do anything for
// release one. This is useful to add log messages that you don't want
@@ -247,7 +253,7 @@ bool setDcheckLevel(bool enabled);
//
// LOG(INFO) << LogString("There are %d items in this set", count);
//
-class LogString {
+class LOGGING_API LogString {
public:
LogString(const char* fmt, ...);
const char* string() const { return mString.data(); }
@@ -258,7 +264,7 @@ private:
// Helper structure used to group the parameters of a LOG() or CHECK()
// statement.
-struct LogParams {
+struct LOGGING_API LogParams {
LogParams() {}
LogParams(const char* a_file,
int a_lineno,
@@ -282,7 +288,7 @@ struct LogParams {
bool quiet = false;
};
-class LogstreamBuf : public std::streambuf {
+class LOGGING_API LogstreamBuf : public std::streambuf {
public:
LogstreamBuf();
@@ -304,7 +310,7 @@ private:
// This also takes a source file, line number and severity to avoid
// storing these in the stack of the functions were LOG() and CHECK()
// statements are called.
-class LogStream {
+class LOGGING_API LogStream {
public:
LogStream(const char* file, int lineno, LogSeverity severity, bool quiet);
~LogStream() = default;
@@ -326,13 +332,13 @@ private:
};
// Add your own types when needed:
-std::ostream& operator<<(std::ostream& stream,
+LOGGING_API std::ostream& operator<<(std::ostream& stream,
const android::base::LogString& str);
-std::ostream& operator<<(std::ostream& stream, const std::string_view& str);
+LOGGING_API std::ostream& operator<<(std::ostream& stream, const std::string_view& str);
// Helper class used to avoid compiler errors, see LOG_LAZY_EVAL for
// more information.
-class LogStreamVoidify {
+class LOGGING_API LogStreamVoidify {
public:
LogStreamVoidify() {}
// This has to be an operator with a precedence lower than << but
@@ -348,7 +354,7 @@ public:
//
// When destroyed, the message sends the final output to the appropriate
// log (e.g. stderr by default).
-class LogMessage {
+class LOGGING_API LogMessage {
public:
// To suppress printing file/line, set quiet = true.
LogMessage(const char* file,
@@ -390,7 +396,7 @@ protected:
// This cannot be a sub-class of LogMessage because the destructor needs
// to restore the saved errno message after sending the message to the
// LogOutput and deleting the stream.
-class ErrnoLogMessage {
+class LOGGING_API ErrnoLogMessage {
public:
ErrnoLogMessage(const char* file,
int line,
@@ -417,7 +423,7 @@ namespace testing {
// Abstract interface to the output where the log messages are sent.
// IMPORTANT: Only use this for unit testing the log facility.
-class LogOutput {
+class LOGGING_API LogOutput {
public:
LogOutput() {}
virtual ~LogOutput() {}
diff --git a/base/include/aemu/base/logging/LogSeverity.h b/base/include/aemu/base/logging/LogSeverity.h
index cde1210..34a2747 100644
--- a/base/include/aemu/base/logging/LogSeverity.h
+++ b/base/include/aemu/base/logging/LogSeverity.h
@@ -13,6 +13,16 @@
// limitations under the License.
#pragma once
+#ifdef _MSC_VER
+#ifdef LOGGING_API_SHARED
+#define LOGGING_API __declspec(dllexport)
+#else
+#define LOGGING_API __declspec(dllimport)
+#endif
+#else
+#define LOGGING_API
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -36,7 +46,9 @@ typedef enum LogSeverity {
#endif
} LogSeverity;
-extern LogSeverity android_log_severity;
+// Returns the minimal log level.
+LOGGING_API LogSeverity getMinLogLevel();
+LOGGING_API void setMinLogLevel(LogSeverity level);
#ifdef __cplusplus
}
diff --git a/base/include/aemu/base/logging/LogTags.h b/base/include/aemu/base/logging/LogTags.h
index e99127b..b9c2668 100644
--- a/base/include/aemu/base/logging/LogTags.h
+++ b/base/include/aemu/base/logging/LogTags.h
@@ -18,7 +18,7 @@ extern "C" {
#ifndef VERBOSE_TAG_LIST
#error "_VERBOSE_TAG(xx, yy) List not defined."
-#endif
+#endif
#define _VERBOSE_TAG(x, y) VERBOSE_##x,
typedef enum {
@@ -26,18 +26,11 @@ typedef enum {
} VerboseTag;
#undef _VERBOSE_TAG
-extern uint64_t android_verbose;
-
-#ifdef __cplusplus
-// Make sure we don't accidentally add in to many tags..
-static_assert(VERBOSE_MAX <= (sizeof(android_verbose) * 8));
-#endif
-
-#define VERBOSE_ENABLE(tag) android_verbose |= (1ULL << VERBOSE_##tag)
-#define VERBOSE_DISABLE(tag) android_verbose &= (1ULL << VERBOSE_##tag)
-#define VERBOSE_CHECK(tag) ((android_verbose & (1ULL << VERBOSE_##tag)) != 0)
-#define VERBOSE_CHECK_ANY() (android_verbose != 0)
+#define VERBOSE_ENABLE(tag) verbose_enable((int64_t) VERBOSE_##tag)
+#define VERBOSE_DISABLE(tag) verbose_disable(int64_t) VERBOSE_##tag)
+#define VERBOSE_CHECK(tag) verbose_check((int64_t) VERBOSE_##tag)
+#define VERBOSE_CHECK_ANY() verbose_check_any();
#define VERBOSE_PRINT(tag, ...) \
if (VERBOSE_CHECK(tag)) { \