mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 01:29:35 +08:00
Limit error handler rate to 1/sec
This commit is contained in:
@@ -4,18 +4,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include <exception>
|
||||
#include <mutex>
|
||||
#include "spdlog/common.h"
|
||||
|
||||
// by default, prints the error to stderr, thread safe
|
||||
// by default, prints the error to stderr, at max rate of 1/sec thread safe
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
class SPDLOG_API err_helper {
|
||||
err_handler custom_err_handler_;
|
||||
std::chrono::steady_clock::time_point last_report_time_;
|
||||
std::mutex mutex_;
|
||||
public:
|
||||
void handle_ex(const std::string& origin, const source_loc& loc, const std::exception& ex) const noexcept;
|
||||
void handle_unknown_ex(const std::string& origin, const source_loc& loc) const noexcept;
|
||||
err_helper() = default;
|
||||
err_helper(const err_helper& other);
|
||||
err_helper(err_helper&& other);
|
||||
void handle_ex(const std::string& origin, const source_loc& loc, const std::exception& ex) noexcept;
|
||||
void handle_unknown_ex(const std::string& origin, const source_loc& loc) noexcept;
|
||||
void set_err_handler(err_handler handler);
|
||||
};
|
||||
} // namespace details
|
||||
|
Reference in New Issue
Block a user