Removed force_flush arg from everywhere. Use flush_on(level) instead

This commit is contained in:
gabime
2016-09-18 00:43:42 +03:00
parent b0f8230783
commit e97621d61d
6 changed files with 56 additions and 48 deletions

View File

@@ -31,9 +31,8 @@ public:
const int open_tries = 5;
const int open_interval = 10;
explicit file_helper(bool force_flush) :
_fd(nullptr),
_force_flush(force_flush)
explicit file_helper() :
_fd(nullptr)
{}
file_helper(const file_helper&) = delete;
@@ -90,10 +89,7 @@ public:
size_t msg_size = msg.formatted.size();
auto data = msg.formatted.data();
if (std::fwrite(data, 1, msg_size, _fd) != msg_size)
throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
if (_force_flush)
std::fflush(_fd);
throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
}
size_t size()
@@ -116,8 +112,7 @@ public:
private:
FILE* _fd;
filename_t _filename;
bool _force_flush;
filename_t _filename;
};
}
}

View File

@@ -39,12 +39,12 @@ inline void spdlog::drop(const std::string &name)
// Create multi/single threaded simple file logger
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_mt(const std::string& logger_name, const filename_t& filename, bool truncate)
{
return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, false, truncate);
return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, truncate);
}
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_st(const std::string& logger_name, const filename_t& filename, bool truncate)
{
return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, false, truncate);
return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, truncate);
}
// Create multi/single threaded rotating file logger