spdlog
Loading...
Searching...
No Matches
backtracer.h
Go to the documentation of this file.
1// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
2// Distributed under the MIT License (http://opensource.org/licenses/MIT)
3
4#pragma once
5
8
9#include <atomic>
10#include <mutex>
11#include <functional>
12
13// Store log messages in circular buffer.
14// Useful for storing debug data in case of error/warning happens.
15
16namespace spdlog {
17namespace details {
19{
21 std::atomic<bool> enabled_{false};
23
24public:
25 backtracer() = default;
26 backtracer(const backtracer &other);
27
29 backtracer &operator=(backtracer other);
30
31 void enable(size_t size);
32 void disable();
33 bool enabled() const;
34 void push_back(const log_msg &msg);
35
36 // pop all items in the q and apply the given fun on each of them.
37 void foreach_pop(std::function<void(const details::log_msg &)> fun);
38};
39
40} // namespace details
41} // namespace spdlog
42
43#ifdef SPDLOG_HEADER_ONLY
44# include "backtracer-inl.h"
45#endif
circular_q< log_msg_buffer > messages_
Definition backtracer.h:22
#define SPDLOG_NOEXCEPT
Definition common.h:53
#define SPDLOG_API
Definition common.h:31
Definition async.h:25