1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/proximity_auth/logging/logging.h"
7 #include "components/proximity_auth/logging/log_buffer.h"
9 namespace proximity_auth
{
12 bool g_logging_enabled
= true;
16 ScopedDisableLoggingForTesting::ScopedDisableLoggingForTesting() {
17 g_logging_enabled
= false;
20 ScopedDisableLoggingForTesting::~ScopedDisableLoggingForTesting() {
21 g_logging_enabled
= true;
24 ScopedLogMessage::ScopedLogMessage(const char* file
,
26 logging::LogSeverity severity
)
27 : file_(file
), line_(line
), severity_(severity
) {
30 ScopedLogMessage::~ScopedLogMessage() {
31 if (!g_logging_enabled
)
34 LogBuffer::GetInstance()->AddLogMessage(LogBuffer::LogMessage(
35 stream_
.str(), base::Time::Now(), file_
, line_
, severity_
));
37 // The destructor of |log_message| also creates a log for the standard logging
39 logging::LogMessage
log_message(file_
, line_
, severity_
);
40 log_message
.stream() << stream_
.str();