2015-03-14 06:06:01 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2016-03-23 22:04:52 +00:00
|
|
|
|
|
|
|
#ifndef ANDROID_BASE_LOGGING_H
|
|
|
|
#define ANDROID_BASE_LOGGING_H
|
2015-03-14 06:06:01 +00:00
|
|
|
|
2015-05-20 05:12:06 +00:00
|
|
|
// NOTE: For Windows, you must include logging.h after windows.h to allow the
|
|
|
|
// following code to suppress the evil ERROR macro:
|
2015-05-04 23:40:38 +00:00
|
|
|
#ifdef _WIN32
|
2015-05-20 05:12:06 +00:00
|
|
|
// windows.h includes wingdi.h which defines an evil macro ERROR.
|
|
|
|
#ifdef ERROR
|
|
|
|
#undef ERROR
|
2015-05-04 23:40:38 +00:00
|
|
|
#endif
|
2015-05-06 23:13:42 +00:00
|
|
|
#endif
|
2015-05-04 23:40:38 +00:00
|
|
|
|
2015-03-27 18:20:14 +00:00
|
|
|
#include <functional>
|
2015-03-14 06:06:01 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <ostream>
|
|
|
|
|
2015-12-05 06:00:26 +00:00
|
|
|
#include "android-base/macros.h"
|
2015-03-14 06:06:01 +00:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace base {
|
|
|
|
|
|
|
|
enum LogSeverity {
|
|
|
|
VERBOSE,
|
|
|
|
DEBUG,
|
|
|
|
INFO,
|
|
|
|
WARNING,
|
|
|
|
ERROR,
|
2016-09-07 17:10:50 +00:00
|
|
|
FATAL_WITHOUT_ABORT,
|
2015-03-14 06:06:01 +00:00
|
|
|
FATAL,
|
|
|
|
};
|
|
|
|
|
2015-03-27 18:20:14 +00:00
|
|
|
enum LogId {
|
2015-03-27 18:20:14 +00:00
|
|
|
DEFAULT,
|
2015-03-27 18:20:14 +00:00
|
|
|
MAIN,
|
|
|
|
SYSTEM,
|
|
|
|
};
|
|
|
|
|
2016-09-08 18:03:58 +00:00
|
|
|
using LogFunction = std::function<void(LogId, LogSeverity, const char*, const char*,
|
|
|
|
unsigned int, const char*)>;
|
|
|
|
using AbortFunction = std::function<void(const char*)>;
|
2015-03-27 18:20:14 +00:00
|
|
|
|
2016-08-04 23:09:39 +00:00
|
|
|
void KernelLogger(LogId, LogSeverity, const char*, const char*, unsigned int, const char*);
|
|
|
|
void StderrLogger(LogId, LogSeverity, const char*, const char*, unsigned int, const char*);
|
2015-03-27 18:20:14 +00:00
|
|
|
|
2016-09-08 18:03:58 +00:00
|
|
|
void DefaultAborter(const char* abort_message);
|
|
|
|
|
2015-03-27 18:20:14 +00:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
// We expose this even though it is the default because a user that wants to
|
|
|
|
// override the default log buffer will have to construct this themselves.
|
|
|
|
class LogdLogger {
|
|
|
|
public:
|
|
|
|
explicit LogdLogger(LogId default_log_id = android::base::MAIN);
|
|
|
|
|
|
|
|
void operator()(LogId, LogSeverity, const char* tag, const char* file,
|
|
|
|
unsigned int line, const char* message);
|
|
|
|
|
|
|
|
private:
|
|
|
|
LogId default_log_id_;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-03-14 06:06:01 +00:00
|
|
|
// Configure logging based on ANDROID_LOG_TAGS environment variable.
|
|
|
|
// We need to parse a string that looks like
|
|
|
|
//
|
|
|
|
// *:v jdwp:d dalvikvm:d dalvikvm-gc:i dalvikvmi:i
|
|
|
|
//
|
|
|
|
// The tag (or '*' for the global level) comes first, followed by a colon and a
|
|
|
|
// letter indicating the minimum priority level we're expected to log. This can
|
|
|
|
// be used to reveal or conceal logs with specific tags.
|
2016-09-08 18:03:58 +00:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
#define INIT_LOGGING_DEFAULT_LOGGER LogdLogger()
|
|
|
|
#else
|
|
|
|
#define INIT_LOGGING_DEFAULT_LOGGER StderrLogger
|
|
|
|
#endif
|
|
|
|
void InitLogging(char* argv[],
|
|
|
|
LogFunction&& logger = INIT_LOGGING_DEFAULT_LOGGER,
|
|
|
|
AbortFunction&& aborter = DefaultAborter);
|
|
|
|
#undef INIT_LOGGING_DEFAULT_LOGGER
|
2015-03-14 06:06:01 +00:00
|
|
|
|
2015-03-27 18:20:14 +00:00
|
|
|
// Replace the current logger.
|
2016-08-04 23:09:39 +00:00
|
|
|
void SetLogger(LogFunction&& logger);
|
2015-09-18 02:36:10 +00:00
|
|
|
|
2016-09-08 18:03:58 +00:00
|
|
|
// Replace the current aborter.
|
|
|
|
void SetAborter(AbortFunction&& aborter);
|
|
|
|
|
2015-09-18 02:36:10 +00:00
|
|
|
class ErrnoRestorer {
|
|
|
|
public:
|
|
|
|
ErrnoRestorer()
|
|
|
|
: saved_errno_(errno) {
|
|
|
|
}
|
|
|
|
|
|
|
|
~ErrnoRestorer() {
|
|
|
|
errno = saved_errno_;
|
|
|
|
}
|
|
|
|
|
2016-03-22 00:46:21 +00:00
|
|
|
// Allow this object to be used as part of && operation.
|
2015-09-18 02:36:10 +00:00
|
|
|
operator bool() const {
|
2016-03-22 00:46:21 +00:00
|
|
|
return true;
|
2015-09-18 02:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
const int saved_errno_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
|
|
|
|
};
|
|
|
|
|
2016-09-23 23:37:12 +00:00
|
|
|
// A helper macro that produces an expression that accepts both a qualified name and an
|
|
|
|
// unqualified name for a LogSeverity, and returns a LogSeverity value.
|
|
|
|
// Note: DO NOT USE DIRECTLY. This is an implementation detail.
|
|
|
|
#define SEVERITY_LAMBDA(severity) ([&]() { \
|
|
|
|
using ::android::base::VERBOSE; \
|
|
|
|
using ::android::base::DEBUG; \
|
|
|
|
using ::android::base::INFO; \
|
|
|
|
using ::android::base::WARNING; \
|
|
|
|
using ::android::base::ERROR; \
|
|
|
|
using ::android::base::FATAL_WITHOUT_ABORT; \
|
|
|
|
using ::android::base::FATAL; \
|
|
|
|
return (severity); }())
|
|
|
|
|
2016-09-22 17:15:01 +00:00
|
|
|
// Defines whether the given severity will be logged or silently swallowed.
|
2016-09-23 23:37:12 +00:00
|
|
|
#define WOULD_LOG(severity) \
|
|
|
|
UNLIKELY((SEVERITY_LAMBDA(severity)) >= ::android::base::GetMinimumLogSeverity())
|
2016-09-22 17:15:01 +00:00
|
|
|
|
|
|
|
// Get an ostream that can be used for logging at the given severity and to the default
|
|
|
|
// destination.
|
|
|
|
//
|
|
|
|
// Notes:
|
|
|
|
// 1) This will not check whether the severity is high enough. One should use WOULD_LOG to filter
|
|
|
|
// usage manually.
|
|
|
|
// 2) This does not save and restore errno.
|
2016-09-23 23:37:12 +00:00
|
|
|
#define LOG_STREAM(severity) LOG_STREAM_TO(DEFAULT, severity)
|
2016-09-22 17:15:01 +00:00
|
|
|
|
|
|
|
// Get an ostream that can be used for logging at the given severity and to the
|
|
|
|
// given destination. The same notes as for LOG_STREAM apply.
|
2016-09-23 23:37:12 +00:00
|
|
|
#define LOG_STREAM_TO(dest, severity) \
|
2016-09-22 17:15:01 +00:00
|
|
|
::android::base::LogMessage(__FILE__, __LINE__, \
|
|
|
|
::android::base::dest, \
|
2016-09-23 23:37:12 +00:00
|
|
|
SEVERITY_LAMBDA(severity), -1).stream()
|
2016-09-22 17:15:01 +00:00
|
|
|
|
2015-03-14 06:06:01 +00:00
|
|
|
// Logs a message to logcat on Android otherwise to stderr. If the severity is
|
|
|
|
// FATAL it also causes an abort. For example:
|
|
|
|
//
|
|
|
|
// LOG(FATAL) << "We didn't expect to reach here";
|
2016-09-23 23:37:12 +00:00
|
|
|
#define LOG(severity) LOG_TO(DEFAULT, severity)
|
2015-03-27 18:20:14 +00:00
|
|
|
|
|
|
|
// Logs a message to logcat with the specified log ID on Android otherwise to
|
|
|
|
// stderr. If the severity is FATAL it also causes an abort.
|
2015-09-18 02:36:10 +00:00
|
|
|
// Use an if-else statement instead of just an if statement here. So if there is a
|
|
|
|
// else statement after LOG() macro, it won't bind to the if statement in the macro.
|
|
|
|
// do-while(0) statement doesn't work here. Because we need to support << operator
|
|
|
|
// following the macro, like "LOG(DEBUG) << xxx;".
|
2016-09-23 23:37:12 +00:00
|
|
|
|
|
|
|
#define LOG_TO(dest, severity) \
|
|
|
|
WOULD_LOG(severity) && \
|
2016-09-22 17:15:01 +00:00
|
|
|
::android::base::ErrnoRestorer() && \
|
2016-09-23 23:37:12 +00:00
|
|
|
LOG_STREAM_TO(dest, severity)
|
2015-03-14 06:06:01 +00:00
|
|
|
|
|
|
|
// A variant of LOG that also logs the current errno value. To be used when
|
|
|
|
// library calls fail.
|
2016-09-23 23:37:12 +00:00
|
|
|
#define PLOG(severity) PLOG_TO(DEFAULT, severity)
|
2015-03-27 18:20:14 +00:00
|
|
|
|
|
|
|
// Behaves like PLOG, but logs to the specified log ID.
|
2016-09-23 23:37:12 +00:00
|
|
|
#define PLOG_TO(dest, severity) \
|
|
|
|
WOULD_LOG(SEVERITY_LAMBDA(severity)) && \
|
2016-09-22 17:15:01 +00:00
|
|
|
::android::base::ErrnoRestorer() && \
|
|
|
|
::android::base::LogMessage(__FILE__, __LINE__, \
|
|
|
|
::android::base::dest, \
|
2016-09-23 23:37:12 +00:00
|
|
|
SEVERITY_LAMBDA(severity), errno).stream()
|
2015-03-14 06:06:01 +00:00
|
|
|
|
|
|
|
// Marker that code is yet to be implemented.
|
|
|
|
#define UNIMPLEMENTED(level) \
|
|
|
|
LOG(level) << __PRETTY_FUNCTION__ << " unimplemented "
|
|
|
|
|
2016-02-26 19:32:14 +00:00
|
|
|
#ifdef __clang_analyzer__
|
|
|
|
// ClangL static analyzer does not see the conditional statement inside
|
|
|
|
// LogMessage's destructor that will abort on FATAL severity.
|
|
|
|
#define ABORT_AFTER_LOG_FATAL for (;;abort())
|
|
|
|
#else
|
|
|
|
#define ABORT_AFTER_LOG_FATAL
|
|
|
|
#endif
|
|
|
|
|
2015-03-14 06:06:01 +00:00
|
|
|
// Check whether condition x holds and LOG(FATAL) if not. The value of the
|
|
|
|
// expression x is only evaluated once. Extra logging can be appended using <<
|
|
|
|
// after. For example:
|
|
|
|
//
|
|
|
|
// CHECK(false == true) results in a log message of
|
|
|
|
// "Check failed: false == true".
|
2015-09-18 02:36:10 +00:00
|
|
|
#define CHECK(x) \
|
2016-03-22 00:46:21 +00:00
|
|
|
LIKELY((x)) || \
|
2016-02-26 19:32:14 +00:00
|
|
|
ABORT_AFTER_LOG_FATAL \
|
2015-09-18 02:36:10 +00:00
|
|
|
::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \
|
|
|
|
::android::base::FATAL, -1).stream() \
|
|
|
|
<< "Check failed: " #x << " "
|
2015-03-14 06:06:01 +00:00
|
|
|
|
|
|
|
// Helper for CHECK_xx(x,y) macros.
|
2015-03-27 18:20:14 +00:00
|
|
|
#define CHECK_OP(LHS, RHS, OP) \
|
|
|
|
for (auto _values = ::android::base::MakeEagerEvaluator(LHS, RHS); \
|
|
|
|
UNLIKELY(!(_values.lhs OP _values.rhs)); \
|
|
|
|
/* empty */) \
|
2016-02-26 19:32:14 +00:00
|
|
|
ABORT_AFTER_LOG_FATAL \
|
2015-03-27 18:20:14 +00:00
|
|
|
::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \
|
|
|
|
::android::base::FATAL, -1).stream() \
|
|
|
|
<< "Check failed: " << #LHS << " " << #OP << " " << #RHS \
|
2015-03-14 06:06:01 +00:00
|
|
|
<< " (" #LHS "=" << _values.lhs << ", " #RHS "=" << _values.rhs << ") "
|
|
|
|
|
|
|
|
// Check whether a condition holds between x and y, LOG(FATAL) if not. The value
|
|
|
|
// of the expressions x and y is evaluated once. Extra logging can be appended
|
|
|
|
// using << after. For example:
|
|
|
|
//
|
|
|
|
// CHECK_NE(0 == 1, false) results in
|
|
|
|
// "Check failed: false != false (0==1=false, false=false) ".
|
|
|
|
#define CHECK_EQ(x, y) CHECK_OP(x, y, == )
|
|
|
|
#define CHECK_NE(x, y) CHECK_OP(x, y, != )
|
|
|
|
#define CHECK_LE(x, y) CHECK_OP(x, y, <= )
|
|
|
|
#define CHECK_LT(x, y) CHECK_OP(x, y, < )
|
|
|
|
#define CHECK_GE(x, y) CHECK_OP(x, y, >= )
|
|
|
|
#define CHECK_GT(x, y) CHECK_OP(x, y, > )
|
|
|
|
|
|
|
|
// Helper for CHECK_STRxx(s1,s2) macros.
|
2016-09-13 17:44:46 +00:00
|
|
|
#define CHECK_STROP(s1, s2, sense) \
|
|
|
|
while (UNLIKELY((strcmp(s1, s2) == 0) != (sense))) \
|
|
|
|
ABORT_AFTER_LOG_FATAL \
|
|
|
|
::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \
|
|
|
|
::android::base::FATAL, -1).stream() \
|
|
|
|
<< "Check failed: " << "\"" << (s1) << "\"" \
|
|
|
|
<< ((sense) ? " == " : " != ") << "\"" << (s2) << "\""
|
2015-03-14 06:06:01 +00:00
|
|
|
|
|
|
|
// Check for string (const char*) equality between s1 and s2, LOG(FATAL) if not.
|
|
|
|
#define CHECK_STREQ(s1, s2) CHECK_STROP(s1, s2, true)
|
|
|
|
#define CHECK_STRNE(s1, s2) CHECK_STROP(s1, s2, false)
|
|
|
|
|
|
|
|
// Perform the pthread function call(args), LOG(FATAL) on error.
|
|
|
|
#define CHECK_PTHREAD_CALL(call, args, what) \
|
|
|
|
do { \
|
|
|
|
int rc = call args; \
|
|
|
|
if (rc != 0) { \
|
|
|
|
errno = rc; \
|
2016-02-26 19:32:14 +00:00
|
|
|
ABORT_AFTER_LOG_FATAL \
|
2016-05-18 22:59:37 +00:00
|
|
|
PLOG(FATAL) << #call << " failed for " << (what); \
|
2015-03-14 06:06:01 +00:00
|
|
|
} \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
// CHECK that can be used in a constexpr function. For example:
|
|
|
|
//
|
|
|
|
// constexpr int half(int n) {
|
|
|
|
// return
|
|
|
|
// DCHECK_CONSTEXPR(n >= 0, , 0)
|
|
|
|
// CHECK_CONSTEXPR((n & 1) == 0),
|
|
|
|
// << "Extra debugging output: n = " << n, 0)
|
|
|
|
// n / 2;
|
|
|
|
// }
|
|
|
|
#define CHECK_CONSTEXPR(x, out, dummy) \
|
|
|
|
(UNLIKELY(!(x))) \
|
|
|
|
? (LOG(FATAL) << "Check failed: " << #x out, dummy) \
|
|
|
|
:
|
|
|
|
|
|
|
|
// DCHECKs are debug variants of CHECKs only enabled in debug builds. Generally
|
|
|
|
// CHECK should be used unless profiling identifies a CHECK as being in
|
|
|
|
// performance critical code.
|
|
|
|
#if defined(NDEBUG)
|
|
|
|
static constexpr bool kEnableDChecks = false;
|
|
|
|
#else
|
|
|
|
static constexpr bool kEnableDChecks = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DCHECK(x) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK(x)
|
|
|
|
#define DCHECK_EQ(x, y) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_EQ(x, y)
|
|
|
|
#define DCHECK_NE(x, y) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_NE(x, y)
|
|
|
|
#define DCHECK_LE(x, y) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_LE(x, y)
|
|
|
|
#define DCHECK_LT(x, y) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_LT(x, y)
|
|
|
|
#define DCHECK_GE(x, y) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_GE(x, y)
|
|
|
|
#define DCHECK_GT(x, y) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_GT(x, y)
|
|
|
|
#define DCHECK_STREQ(s1, s2) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_STREQ(s1, s2)
|
|
|
|
#define DCHECK_STRNE(s1, s2) \
|
|
|
|
if (::android::base::kEnableDChecks) CHECK_STRNE(s1, s2)
|
|
|
|
#if defined(NDEBUG)
|
|
|
|
#define DCHECK_CONSTEXPR(x, out, dummy)
|
|
|
|
#else
|
|
|
|
#define DCHECK_CONSTEXPR(x, out, dummy) CHECK_CONSTEXPR(x, out, dummy)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Temporary class created to evaluate the LHS and RHS, used with
|
|
|
|
// MakeEagerEvaluator to infer the types of LHS and RHS.
|
|
|
|
template <typename LHS, typename RHS>
|
|
|
|
struct EagerEvaluator {
|
2016-09-01 03:55:42 +00:00
|
|
|
constexpr EagerEvaluator(LHS l, RHS r) : lhs(l), rhs(r) {
|
2015-03-14 06:06:01 +00:00
|
|
|
}
|
|
|
|
LHS lhs;
|
|
|
|
RHS rhs;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Helper function for CHECK_xx.
|
|
|
|
template <typename LHS, typename RHS>
|
2016-09-01 03:55:42 +00:00
|
|
|
constexpr EagerEvaluator<LHS, RHS> MakeEagerEvaluator(LHS lhs, RHS rhs) {
|
2015-03-14 06:06:01 +00:00
|
|
|
return EagerEvaluator<LHS, RHS>(lhs, rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Explicitly instantiate EagerEvalue for pointers so that char*s aren't treated
|
|
|
|
// as strings. To compare strings use CHECK_STREQ and CHECK_STRNE. We rely on
|
|
|
|
// signed/unsigned warnings to protect you against combinations not explicitly
|
|
|
|
// listed below.
|
|
|
|
#define EAGER_PTR_EVALUATOR(T1, T2) \
|
|
|
|
template <> \
|
|
|
|
struct EagerEvaluator<T1, T2> { \
|
|
|
|
EagerEvaluator(T1 l, T2 r) \
|
|
|
|
: lhs(reinterpret_cast<const void*>(l)), \
|
|
|
|
rhs(reinterpret_cast<const void*>(r)) { \
|
|
|
|
} \
|
|
|
|
const void* lhs; \
|
|
|
|
const void* rhs; \
|
|
|
|
}
|
|
|
|
EAGER_PTR_EVALUATOR(const char*, const char*);
|
|
|
|
EAGER_PTR_EVALUATOR(const char*, char*);
|
|
|
|
EAGER_PTR_EVALUATOR(char*, const char*);
|
|
|
|
EAGER_PTR_EVALUATOR(char*, char*);
|
|
|
|
EAGER_PTR_EVALUATOR(const unsigned char*, const unsigned char*);
|
|
|
|
EAGER_PTR_EVALUATOR(const unsigned char*, unsigned char*);
|
|
|
|
EAGER_PTR_EVALUATOR(unsigned char*, const unsigned char*);
|
|
|
|
EAGER_PTR_EVALUATOR(unsigned char*, unsigned char*);
|
|
|
|
EAGER_PTR_EVALUATOR(const signed char*, const signed char*);
|
|
|
|
EAGER_PTR_EVALUATOR(const signed char*, signed char*);
|
|
|
|
EAGER_PTR_EVALUATOR(signed char*, const signed char*);
|
|
|
|
EAGER_PTR_EVALUATOR(signed char*, signed char*);
|
|
|
|
|
|
|
|
// Data for the log message, not stored in LogMessage to avoid increasing the
|
|
|
|
// stack size.
|
|
|
|
class LogMessageData;
|
|
|
|
|
|
|
|
// A LogMessage is a temporarily scoped object used by LOG and the unlikely part
|
|
|
|
// of a CHECK. The destructor will abort if the severity is FATAL.
|
|
|
|
class LogMessage {
|
|
|
|
public:
|
2015-03-27 18:20:14 +00:00
|
|
|
LogMessage(const char* file, unsigned int line, LogId id,
|
|
|
|
LogSeverity severity, int error);
|
2015-03-14 06:06:01 +00:00
|
|
|
|
|
|
|
~LogMessage();
|
|
|
|
|
|
|
|
// Returns the stream associated with the message, the LogMessage performs
|
|
|
|
// output when it goes out of scope.
|
|
|
|
std::ostream& stream();
|
|
|
|
|
|
|
|
// The routine that performs the actual logging.
|
2015-03-27 18:20:14 +00:00
|
|
|
static void LogLine(const char* file, unsigned int line, LogId id,
|
|
|
|
LogSeverity severity, const char* msg);
|
2015-03-14 06:06:01 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const std::unique_ptr<LogMessageData> data_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(LogMessage);
|
|
|
|
};
|
|
|
|
|
2016-08-04 23:09:39 +00:00
|
|
|
// Get the minimum severity level for logging.
|
|
|
|
LogSeverity GetMinimumLogSeverity();
|
|
|
|
|
|
|
|
// Set the minimum severity level for logging, returning the old severity.
|
|
|
|
LogSeverity SetMinimumLogSeverity(LogSeverity new_severity);
|
|
|
|
|
2015-03-14 06:06:01 +00:00
|
|
|
// Allows to temporarily change the minimum severity level for logging.
|
|
|
|
class ScopedLogSeverity {
|
|
|
|
public:
|
|
|
|
explicit ScopedLogSeverity(LogSeverity level);
|
|
|
|
~ScopedLogSeverity();
|
|
|
|
|
|
|
|
private:
|
|
|
|
LogSeverity old_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace base
|
|
|
|
} // namespace android
|
|
|
|
|
2016-03-23 22:04:52 +00:00
|
|
|
#endif // ANDROID_BASE_LOGGING_H
|