pairinteraction
A Rydberg Interaction Calculator
LoggerBridge.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Pairinteraction Developers
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#pragma once
5
6#include <spdlog/details/null_mutex.h>
7#include <spdlog/sinks/base_sink.h>
8#include <spdlog/spdlog.h>
9#include <tbb/concurrent_queue.h>
10#include <vector>
11
13public:
14 struct LogEntry {
15 int level = 20;
16 std::string message;
17 };
18
21
22 std::vector<LogEntry> get_pending_logs();
23
24private:
25 tbb::concurrent_queue<LogEntry> log_queue;
26
27 class QueueSink : public spdlog::sinks::base_sink<spdlog::details::null_mutex> {
28 public:
29 explicit QueueSink(LoggerBridge *parent);
30
31 protected:
32 void sink_it_(const spdlog::details::log_msg &msg) override;
33 void flush_() override;
34
35 private:
36 LoggerBridge *parent;
37 };
38
39 std::shared_ptr<spdlog::logger> logger;
40};
std::vector< LogEntry > get_pending_logs()