VCCC  2024.05
VisualCamp Common C++ library
Logger Class Reference

#include <vccc/__log/logger.hpp>

Detailed Description

d for LOGD, i for LOGI, w for LOGW, e for LOGE

supports ostringstream& operator <<

Log.d("Hello, world") // Hello, world
Log.d("First: ", 3, " Second: ", 3.14) // First: 3 Second: 3.14
void d(const Args &... args) const
Log output as debug.
Definition: logger.hpp:69
constexpr VCCC_INLINE_OR_STATIC Logger Log
Global vccc::Logger instance for syntax sugar.
Definition: logger.hpp:139

To use printf-like format, use vccc::Formatter

if ostringstream& operator << is overloaded for user-defined types, it can be printed

Log.d("string: ", std::string("wow!")) // string: wow!
Log.d("Point: ", cv::Point2i(3,4)) // Point: [3, 4]

std::pair, std::tuple, std::integer_sequence, containers, chrono types, aggregate(since C++17) types can be printed.

Log.d(std::vector<std::vector<int>>{{1, 2}, {3}}); // { { 1, 2 }, { 3 } }
Log.d(std::make_tuple(1, "hello")); // { 1, hello }
Log.d(std::chrono::system_clock::now()); // 2021-06-29 14:35:27.917
// Since C++ 17
struct foo {
int x;
std::string name;
};
Log.d(foo{100, "Tony"}); // { 100, Tony }

Public Types

enum  Priority { kDebug , kInfo , kWarn , kError }
 
using stream_type = StreamWrapper
 
using string_type = std::string
 

Public Member Functions

constexpr Logger ()=default
 
template<typename ... Args>
void d (const Args &... args) const
 Log output as debug. More...
 
template<typename ... Args>
void i (const Args &... args) const
 Informational log. More...
 
template<typename ... Args>
void w (const Args &... args) const
 Warning log. More...
 
template<typename ... Args>
void e (const Args &... args) const
 Error log. More...
 
template<typename... Args>
void operator() (Priority priority, const char *tag, const Args &... args) const
 
template<typename ... Args>
string_type to_string (const Args &... args) const
 Return logged value as std::string. More...
 

Static Public Member Functions

static string_typeglobal_separator ()
 Equals to stream_type::global_separator. More...
 

Member Typedef Documentation

◆ stream_type

◆ string_type

using string_type = std::string

Member Enumeration Documentation

◆ Priority

enum Priority
Enumerator
kDebug 
kInfo 
kWarn 
kError 

Constructor & Destructor Documentation

◆ Logger()

constexpr Logger ( )
constexprdefault

Member Function Documentation

◆ d()

void d ( const Args &...  args) const
inline

◆ e()

void e ( const Args &...  args) const
inline

◆ global_separator()

static string_type& global_separator ( )
inlinestatic

◆ i()

void i ( const Args &...  args) const
inline

◆ operator()()

void operator() ( Priority  priority,
const char *  tag,
const Args &...  args 
) const
inline

◆ to_string()

string_type to_string ( const Args &...  args) const
inline
Template Parameters
Args
Parameters
args
Returns
Logged value as std::string

◆ w()

void w ( const Args &...  args) const
inline

The documentation for this class was generated from the following file: