1 #ifndef LIBFILEZILLA_LOGGER_HEADER
2 #define LIBFILEZILLA_LOGGER_HEADER
31 debug_info = 1ull << 5,
32 debug_verbose = 1ull << 6,
33 debug_debug = 1ull << 7,
68 template<
typename String,
typename...Args>
73 do_log(t, std::move(formatted));
82 template<
typename String,
typename...Args>
87 do_log(t, std::move(formatted));
92 template<
typename String>
96 std::wstring formatted =
fz::to_wstring(std::forward<String>(msg));
97 do_log(t, std::move(formatted));
101 template<
typename String>
106 do_log(t, std::move(formatted));
146 std::atomic<uint64_t> level_{logmsg::status | logmsg::error | logmsg::command | logmsg::reply};
149 std::wstring assume_strings_are_utf8(std::string_view
const& arg) {
152 std::wstring assume_strings_are_utf8(std::string
const& arg) {
155 std::wstring assume_strings_are_utf8(
char const* arg) {
159 template <
typename T>
160 T
const& assume_strings_are_utf8(T
const& arg) {
179 null_logger FZ_PUBLIC_SYMBOL & get_null_logger();
Abstract interface for logging strings.
Definition: logger.hpp:51
void log(logmsg::type t, String &&fmt, Args &&...args)
Definition: logger.hpp:69
void log_raw(logmsg::type t, String &&msg)
Logs the raw string, it is not treated as format string.
Definition: logger.hpp:93
void set(logmsg::type t, bool flag)
Sets whether the given types should be logged.
Definition: logger.hpp:126
virtual void do_log(logmsg::type t, std::wstring &&msg)=0
The one thing you need to override.
virtual void disable(logmsg::type t)
Disables logging for the passed message types.
Definition: logger.hpp:141
virtual void enable(logmsg::type t)
Enables logging for the passed message types.
Definition: logger.hpp:136
logmsg::type levels() const
Returns all currently enabled log levels.
Definition: logger.hpp:116
void log_u(logmsg::type t, String &&fmt, Args const &...args)
Definition: logger.hpp:83
bool should_log(logmsg::type t) const
Is any of the passed log levels set.
Definition: logger.hpp:111
virtual void set_all(logmsg::type t)
Sets which message types should be logged.
Definition: logger.hpp:121
A logger that does not log anything.
Definition: logger.hpp:167
virtual void do_log(logmsg::type, std::wstring &&) override
The one thing you need to override.
Definition: logger.hpp:174
virtual void set_all(logmsg::type) override
Sets which message types should be logged.
Definition: logger.hpp:175
virtual void enable(logmsg::type) override
Enables logging for the passed message types.
Definition: logger.hpp:176
A simple logger that writes to stdout.
Definition: logger.hpp:183
virtual void do_log(logmsg::type, std::wstring &&) override
The one thing you need to override.
type
Definition: logger.hpp:16
@ debug_warning
Debug messages aimed at developers.
Definition: logger.hpp:30
@ command
Commands, aimed at the users.
Definition: logger.hpp:24
@ reply
Replies, aimed at the users.
Definition: logger.hpp:27
@ status
Generic status messages aimed at the user.
Definition: logger.hpp:18
@ custom1
Definition: logger.hpp:37
@ error
Error messages aimed at the user.
Definition: logger.hpp:21
The namespace used by libfilezilla.
Definition: apply.hpp:17
std::wstring to_wstring_from_utf8(std::string_view const &in)
Converts from std::string in UTF-8 into std::wstring.
std::wstring to_wstring(std::string_view const &in)
Converts from std::string in system encoding into std::wstring.
std::string sprintf(std::string_view const &fmt, Args &&... args)
A simple type-safe sprintf replacement.
Definition: format.hpp:456