mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 11:29:01 +08:00
@@ -19,7 +19,7 @@ namespace sinks
|
||||
|
||||
/**
|
||||
* This sink prefixes the output with an ANSI escape sequence color code depending on the severity
|
||||
* of the message.
|
||||
* of the message.
|
||||
* If no color terminal detected, omit the escape codes.
|
||||
*/
|
||||
template <class Mutex>
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
_flush();
|
||||
}
|
||||
|
||||
void set_color(level::level_enum color_level, const std::string& color) {
|
||||
void set_color(level::level_enum color_level, const std::string& color)
|
||||
{
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex);
|
||||
colors_[color_level] = color;
|
||||
}
|
||||
@@ -96,10 +97,10 @@ protected:
|
||||
_flush();
|
||||
}
|
||||
|
||||
void _flush() override
|
||||
{
|
||||
fflush(target_file_);
|
||||
}
|
||||
void _flush() override
|
||||
{
|
||||
fflush(target_file_);
|
||||
}
|
||||
FILE* target_file_;
|
||||
bool should_do_colors_;
|
||||
std::map<level::level_enum, std::string> colors_;
|
||||
|
@@ -36,14 +36,14 @@ public:
|
||||
std::lock_guard<Mutex> lock(_mutex);
|
||||
_sink_it(msg);
|
||||
}
|
||||
void flush() SPDLOG_FINAL override
|
||||
{
|
||||
_flush();
|
||||
}
|
||||
void flush() SPDLOG_FINAL override
|
||||
{
|
||||
_flush();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void _sink_it(const details::log_msg& msg) = 0;
|
||||
virtual void _flush() = 0;
|
||||
virtual void _flush() = 0;
|
||||
Mutex _mutex;
|
||||
};
|
||||
}
|
||||
|
@@ -44,15 +44,15 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void _flush() override
|
||||
{
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex);
|
||||
for (auto &sink : _sinks)
|
||||
sink->flush();
|
||||
}
|
||||
void _flush() override
|
||||
{
|
||||
std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex);
|
||||
for (auto &sink : _sinks)
|
||||
sink->flush();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
void add_sink(std::shared_ptr<sink> sink)
|
||||
{
|
||||
|
@@ -33,7 +33,7 @@ public:
|
||||
{
|
||||
_file_helper.open(filename, truncate);
|
||||
}
|
||||
|
||||
|
||||
void set_force_flush(bool force_flush)
|
||||
{
|
||||
_force_flush = force_flush;
|
||||
@@ -46,10 +46,10 @@ protected:
|
||||
if(_force_flush)
|
||||
_file_helper.flush();
|
||||
}
|
||||
void _flush() override
|
||||
{
|
||||
_file_helper.flush();
|
||||
}
|
||||
void _flush() override
|
||||
{
|
||||
_file_helper.flush();
|
||||
}
|
||||
private:
|
||||
details::file_helper _file_helper;
|
||||
bool _force_flush;
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
_current_size = _file_helper.size(); //expensive. called only once
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void _sink_it(const details::log_msg& msg) override
|
||||
{
|
||||
@@ -90,10 +90,10 @@ protected:
|
||||
_file_helper.write(msg);
|
||||
}
|
||||
|
||||
void _flush() override
|
||||
{
|
||||
_file_helper.flush();
|
||||
}
|
||||
void _flush() override
|
||||
{
|
||||
_file_helper.flush();
|
||||
}
|
||||
|
||||
private:
|
||||
static filename_t calc_filename(const filename_t& filename, std::size_t index)
|
||||
@@ -208,10 +208,10 @@ protected:
|
||||
_file_helper.write(msg);
|
||||
}
|
||||
|
||||
void _flush() override
|
||||
{
|
||||
_file_helper.flush();
|
||||
}
|
||||
void _flush() override
|
||||
{
|
||||
_file_helper.flush();
|
||||
}
|
||||
|
||||
private:
|
||||
std::chrono::system_clock::time_point _next_rotation_tp()
|
||||
|
@@ -30,7 +30,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void _sink_it(const details::log_msg& msg) override
|
||||
@@ -38,8 +38,8 @@ protected:
|
||||
OutputDebugStringA(msg.formatted.c_str());
|
||||
}
|
||||
|
||||
void _flush() override
|
||||
{}
|
||||
void _flush() override
|
||||
{}
|
||||
};
|
||||
|
||||
typedef msvc_sink<std::mutex> msvc_sink_mt;
|
||||
|
Reference in New Issue
Block a user