blob: e621576bf5eecdac43b215d0ba5ca97d5c21f134 [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 <ostream>
#include "log_listener.h"
namespace netemul {
namespace internal {
// LogListenerImpl that writes parsed logs to a std::ostream.
class LogListenerOStreamImpl : public LogListenerImpl {
LogListenerOStreamImpl(fidl::InterfaceRequest<fuchsia::logger::LogListenerSafe> request,
std::string prefix, std::ostream* stream,
async_dispatcher_t* dispatcher = nullptr);
virtual void LogImpl(fuchsia::logger::LogMessage m) override;
// FormatTime
// Format the time to monotomic and send it to |stream_|.
void FormatTime(const zx_time_t timestamp);
// FormatTags
// Format the tags and send it to |stream_|.
void FormatTags(const std::vector<std::string>& tags);
// FormatLogLevel
// Format the log level and send it to |stream_|.
void FormatLogLevel(const int32_t severity);
// stream_
// Output stream where formatted logs will be sent to.
std::ostream* stream_;
} // namespace internal
} // namespace netemul