Update mojo sdk to rev c02a28868825edfa57ab77947b8cb15e741c5598
[chromium-blink-merge.git] / components / proximity_auth / logging / logging.cc
blob4ab7920b9e64bfc11e370ad095ffafd713ff27a4
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 {
10 namespace {
12 bool g_logging_enabled = true;
14 } // namespace
16 ScopedDisableLoggingForTesting::ScopedDisableLoggingForTesting() {
17 g_logging_enabled = false;
20 ScopedDisableLoggingForTesting::~ScopedDisableLoggingForTesting() {
21 g_logging_enabled = true;
24 ScopedLogMessage::ScopedLogMessage(const char* file,
25 int line,
26 logging::LogSeverity severity)
27 : file_(file), line_(line), severity_(severity) {
30 ScopedLogMessage::~ScopedLogMessage() {
31 if (!g_logging_enabled)
32 return;
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
38 // system.
39 logging::LogMessage log_message(file_, line_, severity_);
40 log_message.stream() << stream_.str();
43 } // proximity_auth