modernize-use-override

This commit is contained in:
Daniel Chabrowski 2018-02-24 23:56:56 +01:00
parent 7f4c1bb77c
commit fb6df0512f
15 changed files with 38 additions and 42 deletions

View File

@ -65,8 +65,8 @@ public:
void flush() override;
// Error handler
virtual void set_error_handler(log_err_handler) override;
virtual log_err_handler error_handler() override;
void set_error_handler(log_err_handler) override;
log_err_handler error_handler() override;
protected:
void _sink_it(details::log_msg& msg) override;

View File

@ -149,9 +149,9 @@ public:
{
return _msg.c_str();
}
private:
std::string _msg;
};
//

View File

@ -21,18 +21,18 @@ class flag_formatter;
class formatter
{
public:
virtual ~formatter() {}
virtual ~formatter() = default;
virtual void format(details::log_msg& msg) = 0;
};
class pattern_formatter SPDLOG_FINAL : public formatter
{
public:
explicit pattern_formatter(const std::string& pattern, pattern_time_type pattern_time = pattern_time_type::local, const std::string& eol = spdlog::details::os::default_eol);
pattern_formatter(const pattern_formatter&) = delete;
pattern_formatter& operator=(const pattern_formatter&) = delete;
void format(details::log_msg& msg) override;
private:
const std::string _eol;
const std::string _pattern;
@ -45,4 +45,3 @@ private:
}
#include "details/pattern_formatter_impl.h"

View File

@ -37,7 +37,8 @@ public:
colors_[level::critical] = bold + on_red;
colors_[level::off] = reset;
}
virtual ~ansicolor_sink()
~ansicolor_sink() override
{
_flush();
}
@ -79,7 +80,7 @@ public:
const std::string on_white = "\033[47m";
protected:
virtual void _sink_it(const details::log_msg& msg) override
void _sink_it(const details::log_msg& msg) override
{
// Wrap the originally formatted message in color codes.
// If color is not supported in the terminal, log as is instead.
@ -102,6 +103,7 @@ protected:
{
fflush(target_file_);
}
FILE* target_file_;
bool should_do_colors_;
std::unordered_map<level::level_enum, std::string, level::level_hasher> colors_;

View File

@ -26,7 +26,6 @@ class base_sink:public sink
{
public:
base_sink():_mutex() {}
virtual ~base_sink() = default;
base_sink(const base_sink&) = delete;
base_sink& operator=(const base_sink&) = delete;
@ -36,6 +35,7 @@ public:
std::lock_guard<Mutex> lock(_mutex);
_sink_it(msg);
}
void flush() SPDLOG_FINAL override
{
std::lock_guard<Mutex> lock(_mutex);

View File

@ -28,7 +28,6 @@ public:
explicit dist_sink() :_sinks() {}
dist_sink(const dist_sink&) = delete;
dist_sink& operator=(const dist_sink&) = delete;
virtual ~dist_sink() = default;
protected:
std::vector<std::shared_ptr<sink>> _sinks;
@ -51,8 +50,6 @@ protected:
}
public:
void add_sink(std::shared_ptr<sink> sink)
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex);

View File

@ -46,10 +46,12 @@ protected:
if(_force_flush)
_file_helper.flush();
}
void _flush() override
{
_file_helper.flush();
}
private:
details::file_helper _file_helper;
bool _force_flush;
@ -112,7 +114,6 @@ protected:
_file_helper.flush();
}
private:
// Rotate files:
// log.txt -> log.1.txt
@ -142,6 +143,7 @@ private:
}
_file_helper.reopen(true);
}
filename_t _base_filename;
std::size_t _max_size;
std::size_t _max_files;

View File

@ -30,8 +30,6 @@ public:
{
}
protected:
void _sink_it(const details::log_msg& msg) override
{

View File

@ -22,7 +22,6 @@ public:
explicit ostream_sink(std::ostream& os, bool force_flush=false) :_ostream(os), _force_flush(force_flush) {}
ostream_sink(const ostream_sink&) = delete;
ostream_sink& operator=(const ostream_sink&) = delete;
virtual ~ostream_sink() = default;
protected:
void _sink_it(const details::log_msg& msg) override

View File

@ -3,7 +3,6 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include "../details/log_msg.h"
@ -20,7 +19,7 @@ public:
_level = level::trace;
}
virtual ~sink() {}
virtual ~sink() = default;
virtual void log(const details::log_msg& msg) = 0;
virtual void flush() = 0;
@ -30,7 +29,6 @@ public:
private:
level_t _level;
};
inline bool sink::should_log(level::level_enum msg_level) const
@ -50,4 +48,3 @@ inline level::level_enum sink::level() const
}
}

View File

@ -50,13 +50,14 @@ class stderr_sink SPDLOG_FINAL : public base_sink<Mutex>
{
using MyType = stderr_sink<Mutex>;
public:
stderr_sink()
{}
explicit stderr_sink() {}
static std::shared_ptr<MyType> instance()
{
static std::shared_ptr<MyType> instance = std::make_shared<MyType>();
return instance;
}
protected:
void _sink_it(const details::log_msg& msg) override
{

View File

@ -44,7 +44,8 @@ public:
//set ident to be program name if empty
::openlog(_ident.empty()? nullptr:_ident.c_str(), syslog_option, syslog_facility);
}
~syslog_sink()
~syslog_sink() override
{
::closelog();
}

View File

@ -42,7 +42,7 @@ public:
colors_[level::off] = 0;
}
virtual ~wincolor_sink()
~wincolor_sink() override
{
this->flush();
}
@ -58,7 +58,7 @@ public:
}
protected:
virtual void _sink_it(const details::log_msg& msg) override
void _sink_it(const details::log_msg& msg) override
{
auto color = colors_[msg.level];
auto orig_attribs = set_console_attribs(color);
@ -66,7 +66,7 @@ protected:
SetConsoleTextAttribute(out_handle_, orig_attribs); //reset to orig colors
}
virtual void _flush() override
void _flush() override
{
// windows console always flushed?
}