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

---

# llarp/util/logging.hpp



## Namespaces

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

## Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[llarp::log_detail::concat_args_fmt_impl< std::integer_sequence< size_t, I... > >](Classes/structllarp_1_1log__detail_1_1concat__args__fmt__impl_3_01std_1_1integer__sequence_3_01size__t_00_01I_8_8_8_01_4_01_4.md)**  |
| struct | **[llarp::LogTrace](Classes/structllarp_1_1LogTrace.md)**  |
| struct | **[llarp::LogDebug](Classes/structllarp_1_1LogDebug.md)**  |
| struct | **[llarp::LogInfo](Classes/structllarp_1_1LogInfo.md)**  |
| struct | **[llarp::LogWarn](Classes/structllarp_1_1LogWarn.md)**  |
| struct | **[llarp::LogError](Classes/structllarp_1_1LogError.md)**  |

## Defines

|                | Name           |
| -------------- | -------------- |
|  | **[LOKINET_LOG_DEPRECATED](Files/logging_8hpp.md#define-lokinet-log-deprecated)**(Meth)  |




## Macros Documentation

### define LOKINET_LOG_DEPRECATED

```cpp
#define LOKINET_LOG_DEPRECATED(
    Meth
)

```


## Source code

```cpp
#pragma once

// Header for making actual log statements such as llarp::log::Info and so on work.

#include <string>
#include <string_view>
#include <array>

#include <oxen/log.hpp>
#include <oxen/log/ring_buffer_sink.hpp>
#include "oxen/log/internal.hpp"

namespace llarp
{
  namespace log = oxen::log;
}

// Not ready to pollute these deprecation warnings everywhere yet
#if 0
#define LOKINET_LOG_DEPRECATED(Meth) \
  [[deprecated("Use formatted log::" #Meth "(cat, fmt, args...) instead")]]
#else
#define LOKINET_LOG_DEPRECATED(Meth)
#endif

// Deprecated loggers (in the top-level llarp namespace):
namespace llarp
{
  inline std::shared_ptr<log::RingBufferSink> logRingBuffer = nullptr;

  namespace log_detail
  {
    inline log::CategoryLogger legacy_logger = log::Cat("");

    template <typename>
    struct concat_args_fmt_impl;
    template <size_t... I>
    struct concat_args_fmt_impl<std::integer_sequence<size_t, I...>>
    {
      constexpr static std::array<char, sizeof...(I)> format{(I % 2 == 0 ? '{' : '}')...};
    };
    template <size_t N>
    constexpr std::string_view
    concat_args_fmt()
    {
      return std::string_view{
          concat_args_fmt_impl<std::make_index_sequence<2 * N>>::format.data(), 2 * N};
    }
  }  // namespace log_detail

  template <typename... T>
  struct LOKINET_LOG_DEPRECATED(Trace) LogTrace : log::trace<T...>
  {
    LogTrace(
        T&&... args,
        const log::slns::source_location& location = log::slns::source_location::current())
        : log::trace<T...>::trace{
            log_detail::legacy_logger,
            log_detail::concat_args_fmt<sizeof...(T)>(),
            std::forward<T>(args)...,
            location}
    {}
  };
  template <typename... T>
  struct LOKINET_LOG_DEPRECATED(Debug) LogDebug : log::debug<T...>
  {
    LogDebug(
        T&&... args,
        const log::slns::source_location& location = log::slns::source_location::current())
        : log::debug<T...>::debug{
            log_detail::legacy_logger,
            log_detail::concat_args_fmt<sizeof...(T)>(),
            std::forward<T>(args)...,
            location}
    {}
  };
  template <typename... T>
  struct LOKINET_LOG_DEPRECATED(Info) LogInfo : log::info<T...>
  {
    LogInfo(
        T&&... args,
        const log::slns::source_location& location = log::slns::source_location::current())
        : log::info<T...>::info{
            log_detail::legacy_logger,
            log_detail::concat_args_fmt<sizeof...(T)>(),
            std::forward<T>(args)...,
            location}
    {}
  };
  template <typename... T>
  struct LOKINET_LOG_DEPRECATED(Warning) LogWarn : log::warning<T...>
  {
    LogWarn(
        T&&... args,
        const log::slns::source_location& location = log::slns::source_location::current())
        : log::warning<T...>::warning{
            log_detail::legacy_logger,
            log_detail::concat_args_fmt<sizeof...(T)>(),
            std::forward<T>(args)...,
            location}
    {}
  };
  template <typename... T>
  struct LOKINET_LOG_DEPRECATED(Error) LogError : log::error<T...>
  {
    LogError(
        T&&... args,
        const log::slns::source_location& location = log::slns::source_location::current())
        : log::error<T...>::error{
            log_detail::legacy_logger,
            log_detail::concat_args_fmt<sizeof...(T)>(),
            std::forward<T>(args)...,
            location}
    {}
  };

  template <typename... T>
  LogTrace(T&&...) -> LogTrace<T...>;

  template <typename... T>
  LogDebug(T&&...) -> LogDebug<T...>;

  template <typename... T>
  LogInfo(T&&...) -> LogInfo<T...>;

  template <typename... T>
  LogWarn(T&&...) -> LogWarn<T...>;

  template <typename... T>
  LogError(T&&...) -> LogError<T...>;

}  // namespace llarp
```


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

Updated on 2023-01-26 at 19:35:18 +0000
