1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "mozilla/Likely.h"
9 #include "mozilla/MacroArgs.h"
12 #include <android/log.h>
13 #define LOG(...) __android_log_print(ANDROID_LOG_INFO, "GeckoLinker", __VA_ARGS__)
14 #define WARN(...) __android_log_print(ANDROID_LOG_WARN, "GeckoLinker", __VA_ARGS__)
15 #define ERROR(...) __android_log_print(ANDROID_LOG_ERROR, "GeckoLinker", __VA_ARGS__)
19 /* Expand to 1 or m depending on whether there is one argument or more
21 #define MOZ_ONE_OR_MORE_ARGS_IMPL2(_1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) \
23 #define MOZ_ONE_OR_MORE_ARGS_IMPL(args) MOZ_ONE_OR_MORE_ARGS_IMPL2 args
24 #define MOZ_ONE_OR_MORE_ARGS(...) \
25 MOZ_ONE_OR_MORE_ARGS_IMPL((__VA_ARGS__, m, m, m, m, m, m, m, m, 1, 0))
27 #define MOZ_MACRO_GLUE(a, b) a b
29 /* Some magic to choose between LOG1 and LOGm depending on the number of
31 #define MOZ_CHOOSE_LOG(...) \
32 MOZ_MACRO_GLUE(MOZ_CONCAT(LOG, MOZ_ONE_OR_MORE_ARGS(__VA_ARGS__)), \
35 #define LOG1(format) fprintf(stderr, format "\n")
36 #define LOGm(format, ...) fprintf(stderr, format "\n", __VA_ARGS__)
37 #define LOG(...) MOZ_CHOOSE_LOG(__VA_ARGS__)
38 #define WARN(...) MOZ_CHOOSE_LOG("Warning: " __VA_ARGS__)
39 #define ERROR(...) MOZ_CHOOSE_LOG("Error: " __VA_ARGS__)
46 static bool isVerbose()
48 return Singleton
.verbose
;
57 const char *env
= getenv("MOZ_DEBUG_LINKER");
58 if (env
&& *env
== '1')
59 Singleton
.verbose
= true;
63 static Logging Singleton
;
66 #define DEBUG_LOG(...) \
68 if (MOZ_UNLIKELY(Logging::isVerbose())) { \
73 #endif /* Logging_h */