blob: a290ef50c243e2ddbac5bb78c7ced46b749d05ce [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/developer/debug/shared/logging/logging.h"
#include <stdio.h>
namespace debug_ipc {
LogStatement::LogStatement(FileLineFunction origin, LogCategory category)
: origin_(std::move(origin)), category_(category) {
should_log_ = false;
if (!IsLogCategoryActive(category_))
return;
start_time_ = SecondsSinceStart();
should_log_ = true;
PushLogEntry(this);
}
std::string LogStatement::GetMsg() {
return stream_.str();
}
LogStatement::~LogStatement() {
if (!IsLogCategoryActive(category_))
return;
if (!should_log_)
return;
PopLogEntry(category_, origin_, stream_.str(), start_time_, SecondsSinceStart());
}
} // namespace debug_ipc
// namespace debug_ipc