mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 10:31:34 +08:00
Changed "auto_flush" to "force_flush" to better represent the meaning
This commit is contained in:
parent
06ef01f867
commit
7635455c8d
@ -48,9 +48,9 @@ public:
|
|||||||
const int open_tries = 5;
|
const int open_tries = 5;
|
||||||
const int open_interval = 10;
|
const int open_interval = 10;
|
||||||
|
|
||||||
explicit file_helper(bool auto_flush):
|
explicit file_helper(bool force_flush):
|
||||||
_fd(nullptr),
|
_fd(nullptr),
|
||||||
_auto_flush(auto_flush)
|
_force_flush(force_flush)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
file_helper(const file_helper&) = delete;
|
file_helper(const file_helper&) = delete;
|
||||||
@ -104,7 +104,7 @@ public:
|
|||||||
if(std::fwrite(data, 1, size, _fd) != size)
|
if(std::fwrite(data, 1, size, _fd) != size)
|
||||||
throw spdlog_ex("Failed writing to file " + _filename);
|
throw spdlog_ex("Failed writing to file " + _filename);
|
||||||
|
|
||||||
if(_auto_flush)
|
if(_force_flush)
|
||||||
std::fflush(_fd);
|
std::fflush(_fd);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
FILE* _fd;
|
FILE* _fd;
|
||||||
std::string _filename;
|
std::string _filename;
|
||||||
bool _auto_flush;
|
bool _force_flush;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -43,24 +43,24 @@ inline void spdlog::drop(const std::string &name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create multi/single threaded rotating file logger
|
// Create multi/single threaded rotating file logger
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool auto_flush)
|
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool force_flush)
|
||||||
{
|
{
|
||||||
return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, "txt", max_file_size, max_files, auto_flush);
|
return create<spdlog::sinks::rotating_file_sink_mt>(logger_name, filename, "txt", max_file_size, max_files, force_flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_st(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool auto_flush)
|
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_st(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool force_flush)
|
||||||
{
|
{
|
||||||
return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, "txt", max_file_size, max_files, auto_flush);
|
return create<spdlog::sinks::rotating_file_sink_st>(logger_name, filename, "txt", max_file_size, max_files, force_flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create file logger which creates new file at midnight):
|
// Create file logger which creates new file at midnight):
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_mt(const std::string& logger_name, const std::string& filename, bool auto_flush)
|
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_mt(const std::string& logger_name, const std::string& filename, bool force_flush)
|
||||||
{
|
{
|
||||||
return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, "txt", auto_flush);
|
return create<spdlog::sinks::daily_file_sink_mt>(logger_name, filename, "txt", force_flush);
|
||||||
}
|
}
|
||||||
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string& logger_name, const std::string& filename, bool auto_flush)
|
inline std::shared_ptr<spdlog::logger> spdlog::daily_logger_st(const std::string& logger_name, const std::string& filename, bool force_flush)
|
||||||
{
|
{
|
||||||
return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, "txt", auto_flush);
|
return create<spdlog::sinks::daily_file_sink_st>(logger_name, filename, "txt", force_flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ class simple_file_sink : public base_sink<Mutex>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit simple_file_sink(const std::string &filename,
|
explicit simple_file_sink(const std::string &filename,
|
||||||
bool auto_flush=false):
|
bool force_flush=false):
|
||||||
_file_helper(auto_flush)
|
_file_helper(force_flush)
|
||||||
{
|
{
|
||||||
_file_helper.open(filename);
|
_file_helper.open(filename);
|
||||||
}
|
}
|
||||||
@ -71,13 +71,13 @@ class rotating_file_sink : public base_sink<Mutex>
|
|||||||
public:
|
public:
|
||||||
rotating_file_sink(const std::string &base_filename, const std::string &extension,
|
rotating_file_sink(const std::string &base_filename, const std::string &extension,
|
||||||
std::size_t max_size, std::size_t max_files,
|
std::size_t max_size, std::size_t max_files,
|
||||||
bool auto_flush=false):
|
bool force_flush=false):
|
||||||
_base_filename(base_filename),
|
_base_filename(base_filename),
|
||||||
_extension(extension),
|
_extension(extension),
|
||||||
_max_size(max_size),
|
_max_size(max_size),
|
||||||
_max_files(max_files),
|
_max_files(max_files),
|
||||||
_current_size(0),
|
_current_size(0),
|
||||||
_file_helper(auto_flush)
|
_file_helper(force_flush)
|
||||||
{
|
{
|
||||||
_file_helper.open(calc_filename(_base_filename, 0, _extension));
|
_file_helper.open(calc_filename(_base_filename, 0, _extension));
|
||||||
}
|
}
|
||||||
@ -157,11 +157,11 @@ class daily_file_sink:public base_sink<Mutex>
|
|||||||
public:
|
public:
|
||||||
explicit daily_file_sink(const std::string& base_filename,
|
explicit daily_file_sink(const std::string& base_filename,
|
||||||
const std::string& extension,
|
const std::string& extension,
|
||||||
bool auto_flush=false):
|
bool force_flush=false):
|
||||||
_base_filename(base_filename),
|
_base_filename(base_filename),
|
||||||
_extension(extension),
|
_extension(extension),
|
||||||
_midnight_tp (_calc_midnight_tp() ),
|
_midnight_tp (_calc_midnight_tp() ),
|
||||||
_file_helper(auto_flush)
|
_file_helper(force_flush)
|
||||||
{
|
{
|
||||||
_file_helper.open(calc_filename(_base_filename, _extension));
|
_file_helper.open(calc_filename(_base_filename, _extension));
|
||||||
}
|
}
|
||||||
|
@ -70,14 +70,14 @@ void set_sync_mode();
|
|||||||
//
|
//
|
||||||
// Create multi/single threaded rotating file logger
|
// Create multi/single threaded rotating file logger
|
||||||
//
|
//
|
||||||
std::shared_ptr<logger> rotating_logger_mt(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool auto_flush = false);
|
std::shared_ptr<logger> rotating_logger_mt(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool force_flush = false);
|
||||||
std::shared_ptr<logger> rotating_logger_st(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool auto_flush = false);
|
std::shared_ptr<logger> rotating_logger_st(const std::string& logger_name, const std::string& filename, size_t max_file_size, size_t max_files, bool force_flush = false);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create file logger which creates new file at midnight):
|
// Create file logger which creates new file at midnight):
|
||||||
//
|
//
|
||||||
std::shared_ptr<logger> daily_logger_mt(const std::string& logger_name, const std::string& filename, bool auto_flush = false);
|
std::shared_ptr<logger> daily_logger_mt(const std::string& logger_name, const std::string& filename, bool force_flush = false);
|
||||||
std::shared_ptr<logger> daily_logger_st(const std::string& logger_name, const std::string& filename, bool auto_flush = false);
|
std::shared_ptr<logger> daily_logger_st(const std::string& logger_name, const std::string& filename, bool force_flush = false);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user