Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/spdlog/details/backtracer.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
0002 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
0003 
0004 #pragma once
0005 
0006 #include <spdlog/details/circular_q.h>
0007 #include <spdlog/details/log_msg_buffer.h>
0008 
0009 #include <atomic>
0010 #include <functional>
0011 #include <mutex>
0012 
0013 // Store log messages in circular buffer.
0014 // Useful for storing debug data in case of error/warning happens.
0015 
0016 namespace spdlog {
0017 namespace details {
0018 class SPDLOG_API backtracer {
0019     mutable std::mutex mutex_;
0020     std::atomic<bool> enabled_{false};
0021     circular_q<log_msg_buffer> messages_;
0022 
0023 public:
0024     backtracer() = default;
0025     backtracer(const backtracer &other);
0026 
0027     backtracer(backtracer &&other) SPDLOG_NOEXCEPT;
0028     backtracer &operator=(backtracer other);
0029 
0030     void enable(size_t size);
0031     void disable();
0032     bool enabled() const;
0033     void push_back(const log_msg &msg);
0034     bool empty() const;
0035 
0036     // pop all items in the q and apply the given fun on each of them.
0037     void foreach_pop(std::function<void(const details::log_msg &)> fun);
0038 };
0039 
0040 }  // namespace details
0041 }  // namespace spdlog
0042 
0043 #ifdef SPDLOG_HEADER_ONLY
0044     #include "backtracer-inl.h"
0045 #endif