---
title: llarp/util/logging/logstream.hpp

---

# llarp/util/logging/logstream.hpp



## Namespaces

| Name           |
| -------------- |
| **[llarp](Namespaces/namespacellarp.md)** <br>[crypto.hpp] |

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::ILogStream](Classes/structllarp_1_1ILogStream.md)** <br>logger stream interface  |




## Source code

```cpp
#pragma once
#include "loglevel.hpp"

#include <llarp/util/time.hpp>

#include <memory>
#include <string>
#include <sstream>
#include <string_view>

namespace llarp
{
  struct ILogStream
  {
    virtual ~ILogStream() = default;

    virtual void
    PreLog(
        std::stringstream& out,
        LogLevel lvl,
        std::string_view filename,
        int lineno,
        const std::string& nodename) const = 0;

    virtual void
    Print(LogLevel lvl, std::string_view filename, const std::string& msg) = 0;

    virtual void
    PostLog(std::stringstream& out) const = 0;

    virtual void
    AppendLog(
        LogLevel lvl,
        std::string_view filename,
        int lineno,
        const std::string& nodename,
        const std::string msg)
    {
      std::stringstream ss;
      PreLog(ss, lvl, filename, lineno, nodename);
      ss << msg;
      PostLog(ss);
      Print(lvl, filename, ss.str());
    }

    virtual void
    ImmediateFlush() = 0;

    virtual void
    Tick(llarp_time_t now) = 0;
  };

  using ILogStream_ptr = std::unique_ptr<ILogStream>;

}  // namespace llarp
```


-------------------------------

Updated on 2022-05-20 at 15:34:08 +0000
