mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-01 02:49:03 +08:00
bench
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "../common.h"
|
||||
#include "os.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +25,8 @@ namespace details
|
||||
class file_helper
|
||||
{
|
||||
public:
|
||||
static const int open_max_tries = 5;
|
||||
static const int sleep_ms_bewteen_tries = 10;
|
||||
const int open_tries = 5;
|
||||
const int open_interval = 10;
|
||||
|
||||
explicit file_helper(const std::size_t flush_inverval):
|
||||
_fd(nullptr),
|
||||
@@ -40,21 +41,21 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void open(const std::string& filename)
|
||||
void open(const std::string& fname)
|
||||
{
|
||||
|
||||
close();
|
||||
|
||||
_filename = filename;
|
||||
for (int tries = 0; tries < open_max_tries; ++tries)
|
||||
_filename = fname;
|
||||
for (int tries = 0; tries < open_tries; ++tries)
|
||||
{
|
||||
if(!os::fopen_s(&_fd, filename, "wb"))
|
||||
if(!os::fopen_s(&_fd, fname, "wb"))
|
||||
return;
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(sleep_ms_bewteen_tries));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(open_interval));
|
||||
}
|
||||
|
||||
throw spdlog_ex("Failed opening file " + filename + " for writing");
|
||||
throw spdlog_ex("Failed opening file " + fname + " for writing");
|
||||
}
|
||||
|
||||
void close()
|
||||
|
@@ -9,9 +9,6 @@
|
||||
|
||||
#include<vector>
|
||||
#include<memory>
|
||||
#include<atomic>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
#include "sinks/base_sink.h"
|
||||
#include "common.h"
|
||||
|
||||
@@ -75,19 +72,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Trace & debug macros
|
||||
//
|
||||
#ifdef FFLOG_ENABLE_TRACE
|
||||
#define FFLOG_TRACE(logger, ...) logger->log(spdlog::level::TRACE, __FILE__, " #", __LINE__,": " __VA_ARGS__)
|
||||
#else
|
||||
#define FFLOG_TRACE(logger, ...) {}
|
||||
#endif
|
||||
|
||||
#ifdef FFLOG_ENABLE_DEBUG
|
||||
#define FFLOG_DEBUG(logger, ...) logger->log(spdlog::level::DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
#define FFLOG_DEBUG(logger, ...) {}
|
||||
#endif
|
||||
|
||||
#include "./details/logger_impl.h"
|
||||
|
Reference in New Issue
Block a user