31#include "string_format.h"
32#include "string_help.h"
52 static std::recursive_mutex
mutex;
61 virtual void log(
const std::string &type,
const std::string &text) = 0;
69 void log_event(
const std::string &type,
const std::string &text);
72 void log_event(
const std::string &type,
const std::string &format, Arg1 arg1)
77 template <
class Arg1,
class Arg2>
78 void log_event(
const std::string &type,
const std::string &format, Arg1 arg1, Arg2 arg2)
83 template <
class Arg1,
class Arg2,
class Arg3>
84 void log_event(
const std::string &type,
const std::string &format, Arg1 arg1, Arg2 arg2, Arg3 arg3)
89 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
90 void log_event(
const std::string &type,
const std::string &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
92 StringFormat f(format);
f.set_arg(1, arg1);
f.set_arg(2, arg2);
f.set_arg(3, arg3);
f.set_arg(4, arg4);
log_event(type,
f.get_result());
95 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
96 void log_event(
const std::string &type,
const std::string &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
98 StringFormat f(format);
f.set_arg(1, arg1);
f.set_arg(2, arg2);
f.set_arg(3, arg3);
f.set_arg(4, arg4);
f.set_arg(5, arg5);
log_event(type,
f.get_result());
101 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class Arg6>
102 void log_event(
const std::string &type,
const std::string &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
104 StringFormat f(format);
f.set_arg(1, arg1);
f.set_arg(2, arg2);
f.set_arg(3, arg3);
f.set_arg(4, arg4);
f.set_arg(5, arg5);
f.set_arg(6, arg6);
log_event(type,
f.get_result());
107 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class Arg6,
class Arg7>
108 void log_event(
const std::string &type,
const std::string &format, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6, Arg7 arg7)
110 StringFormat f(format);
f.set_arg(1, arg1);
f.set_arg(2, arg2);
f.set_arg(3, arg3);
f.set_arg(4, arg4);
f.set_arg(5, arg5);
f.set_arg(6, arg6);
f.set_arg(7, arg7);
log_event(type,
f.get_result());
Logger interface.
Definition logger.h:42
static StringFormat get_log_string(const std::string &type, const std::string &text)
void enable()
Enable logger for logging.
static std::vector< Logger * > instances
Pointers to currently enabled logger.
Definition logger.h:49
virtual void log(const std::string &type, const std::string &text)=0
Log text.
void disable()
Disable logging.
static std::recursive_mutex mutex
Logger mutex object.
Definition logger.h:52
Logger()
Constructs a logger.
void log_event(const std::string &type, const std::string &text)
Log text to logger.