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

@ -31,7 +31,7 @@ namespace details
class async_log_helper;
}
class async_logger SPDLOG_FINAL :public logger
class async_logger SPDLOG_FINAL : public logger
{
public:
template<class It>
@ -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

@ -136,7 +136,7 @@ namespace os
std::string errno_str(int err_num);
}
}
class spdlog_ex: public std::exception
class spdlog_ex : public std::exception
{
public:
spdlog_ex(const std::string& msg):_msg(msg)
@ -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

@ -23,7 +23,7 @@ namespace sinks
* If no color terminal detected, omit the escape codes.
*/
template <class Mutex>
class ansicolor_sink: public base_sink<Mutex>
class ansicolor_sink : public base_sink<Mutex>
{
public:
ansicolor_sink(FILE* file): target_file_(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

@ -22,11 +22,10 @@ namespace spdlog
namespace sinks
{
template<class Mutex>
class base_sink:public sink
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

@ -22,13 +22,12 @@ namespace spdlog
namespace sinks
{
template<class Mutex>
class dist_sink: public base_sink<Mutex>
class dist_sink : public base_sink<Mutex>
{
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

@ -26,7 +26,7 @@ namespace sinks
* Trivial file sink with single file as target
*/
template<class Mutex>
class simple_file_sink SPDLOG_FINAL : public base_sink < Mutex >
class simple_file_sink SPDLOG_FINAL : public base_sink<Mutex>
{
public:
explicit simple_file_sink(const filename_t &filename, bool truncate = false):_force_flush(false)
@ -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

@ -23,15 +23,13 @@ namespace sinks
* MSVC sink (logging using OutputDebugStringA)
*/
template<class Mutex>
class msvc_sink : public base_sink < Mutex >
class msvc_sink : public base_sink<Mutex>
{
public:
explicit msvc_sink()
{
}
protected:
void _sink_it(const details::log_msg& msg) override
{

View File

@ -16,7 +16,7 @@ namespace sinks
{
template <class Mutex>
class null_sink : public base_sink < Mutex >
class null_sink : public base_sink<Mutex>
{
protected:
void _sink_it(const details::log_msg&) override

View File

@ -16,13 +16,12 @@ namespace spdlog
namespace sinks
{
template<class Mutex>
class ostream_sink: public base_sink<Mutex>
class ostream_sink : public base_sink<Mutex>
{
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

@ -21,8 +21,8 @@ namespace sinks
/*
* Windows color console sink. Uses WriteConsoleA to write to the console with colors
*/
template<class Mutex>
class wincolor_sink: public base_sink<Mutex>
template <class Mutex>
class wincolor_sink : public base_sink<Mutex>
{
public:
const WORD BOLD = FOREGROUND_INTENSITY;
@ -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?
}
@ -92,8 +92,8 @@ private:
//
// windows color console to stdout
//
template<class Mutex>
class wincolor_stdout_sink: public wincolor_sink<Mutex>
template <class Mutex>
class wincolor_stdout_sink : public wincolor_sink<Mutex>
{
public:
wincolor_stdout_sink() : wincolor_sink<Mutex>(GetStdHandle(STD_OUTPUT_HANDLE))
@ -106,8 +106,8 @@ using wincolor_stdout_sink_st = wincolor_stdout_sink<details::null_mutex>;
//
// windows color console to stderr
//
template<class Mutex>
class wincolor_stderr_sink: public wincolor_sink<Mutex>
template <class Mutex>
class wincolor_stderr_sink : public wincolor_sink<Mutex>
{
public:
wincolor_stderr_sink() : wincolor_sink<Mutex>(GetStdHandle(STD_ERROR_HANDLE))

View File

@ -17,7 +17,7 @@ namespace sinks
/*
* Windows debug sink (logging using OutputDebugStringA, synonym for msvc_sink)
*/
template<class Mutex>
template <class Mutex>
using windebug_sink = msvc_sink<Mutex>;
using windebug_sink_mt = msvc_sink_mt;