mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-15 08:01:30 +08:00
Some syntactic improvements
This commit is contained in:
parent
b49b086723
commit
068a0e3a6b
@ -6,12 +6,11 @@
|
|||||||
#include "fast_oss.h"
|
#include "fast_oss.h"
|
||||||
|
|
||||||
|
|
||||||
// line_logger class.
|
// Line logger class - aggregates operator<< calls to fast ostream
|
||||||
// aggregates single log line (on the stack if possibe) and calls the logger upon destruction
|
// and logs upon destruction
|
||||||
|
|
||||||
namespace c11log
|
namespace c11log
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace details
|
namespace details
|
||||||
{
|
{
|
||||||
class line_logger
|
class line_logger
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
using sink_ptr = std::shared_ptr<sinks::isink>;
|
using sink_ptr = std::shared_ptr<sinks::isink>;
|
||||||
using sinks_vector_t = std::vector<sink_ptr>;
|
using sinks_vector_t = std::vector<sink_ptr>;
|
||||||
using sinks_init_list = std::initializer_list<sink_ptr>;
|
using sinks_init_list = std::initializer_list<sink_ptr>;
|
||||||
using formatter_ptr = std::unique_ptr<c11log::formatters::formatter>;
|
using formatter_ptr = std::unique_ptr<formatters::formatter>;
|
||||||
|
|
||||||
logger(const std::string& name, sinks_init_list, formatter_ptr = nullptr);
|
logger(const std::string& name, sinks_init_list, formatter_ptr = nullptr);
|
||||||
logger(const std::string& name, sink_ptr, formatter_ptr = nullptr);
|
logger(const std::string& name, sink_ptr, formatter_ptr = nullptr);
|
||||||
@ -37,12 +37,11 @@ public:
|
|||||||
logger& operator=(const logger&) = delete;
|
logger& operator=(const logger&) = delete;
|
||||||
~logger() = default;
|
~logger() = default;
|
||||||
|
|
||||||
|
void level(level::level_enum);
|
||||||
void level(c11log::level::level_enum);
|
level::level_enum level() const;
|
||||||
c11log::level::level_enum level() const;
|
|
||||||
|
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
bool should_log(c11log::level::level_enum) const;
|
bool should_log(level::level_enum) const;
|
||||||
|
|
||||||
template<typename T> details::line_logger trace(const T&);
|
template<typename T> details::line_logger trace(const T&);
|
||||||
template<typename T> details::line_logger debug(const T&);
|
template<typename T> details::line_logger debug(const T&);
|
||||||
@ -60,11 +59,9 @@ public:
|
|||||||
details::line_logger critical();
|
details::line_logger critical();
|
||||||
details::line_logger fatal();
|
details::line_logger fatal();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend details::line_logger;
|
friend details::line_logger;
|
||||||
|
std::string _name;
|
||||||
std::string _logger_name;
|
|
||||||
formatter_ptr _formatter;
|
formatter_ptr _formatter;
|
||||||
sinks_vector_t _sinks;
|
sinks_vector_t _sinks;
|
||||||
std::atomic_int _level;
|
std::atomic_int _level;
|
||||||
@ -97,7 +94,7 @@ inline std::shared_ptr<c11log::logger> c11log::get_logger(const std::string& nam
|
|||||||
|
|
||||||
|
|
||||||
inline c11log::logger::logger(const std::string& name, sinks_init_list sinks_list, formatter_ptr f) :
|
inline c11log::logger::logger(const std::string& name, sinks_init_list sinks_list, formatter_ptr f) :
|
||||||
_logger_name(name),
|
_name(name),
|
||||||
_formatter(std::move(f)),
|
_formatter(std::move(f)),
|
||||||
_sinks(sinks_list)
|
_sinks(sinks_list)
|
||||||
{
|
{
|
||||||
@ -195,7 +192,7 @@ inline c11log::details::line_logger c11log::logger::fatal()
|
|||||||
|
|
||||||
inline const std::string& c11log::logger::name() const
|
inline const std::string& c11log::logger::name() const
|
||||||
{
|
{
|
||||||
return _logger_name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void c11log::logger::level(c11log::level::level_enum level)
|
inline void c11log::logger::level(c11log::level::level_enum level)
|
||||||
|
Loading…
Reference in New Issue
Block a user