This commit is contained in:
gabime
2014-10-31 16:34:48 +02:00
parent 31971bf63b
commit 2d075bcfda
9 changed files with 98 additions and 118 deletions

View File

@@ -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()

View File

@@ -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"