50 #define __func__ __FUNCTION__
123 typedef std::pair<const std::string, severity>
logd;
213 bool show_names =
true,
bool do_indent =
false,
bool show_timestamps =
true,
bool break_strict =
true,
bool auto_newline =
true)
const;
243 std::chrono::steady_clock::time_point
start_;
278 #define log_scope(description) lg::scope_logger scope_logging_object__(lg::general(), description);
279 #define log_scope2(domain,description) lg::scope_logger scope_logging_object__(domain, description);
281 #define LOG_STREAM(level, domain) if (lg::level().dont_log(domain)) ; else lg::level()(domain) | formatter()
284 #define LOG_STREAM_NAMELESS(level, domain) if (lg::level().dont_log(domain)) ; else lg::level()(domain, false) | formatter()
287 #define LOG_STREAM_NAMELESS_STREAMING(level, domain) if (lg::level().dont_log(domain)) ; else lg::level()(domain, false, false, true, true, false) | formatter()
290 #define LOG_STREAM_INDENT(level,domain) if (lg::level().dont_log(domain)) ; else lg::level()(domain, true, true) | formatter()
294 #define FORCE_LOG_TO(logger, domain) logger(domain) | formatter()
299 #define PLAIN_LOG lg::err()(lg::general(), false, false, false, false, true) | formatter()
300 #define STREAMING_LOG lg::err()(lg::general(), false, false, false, false, false) | formatter()
log_domain(char const *name, severity severity=severity::LG_WARN)
void operator|(formatter &&message)
void set_auto_newline(bool enabled)
void set_prefix(const std::string &prefix)
void set_indent(int level)
log_in_progress(std::ostream &stream)
std::string get_name() const
logger(char const *name, severity severity)
log_in_progress operator()(const log_domain &domain, bool show_names=true, bool do_indent=false, bool show_timestamps=true, bool break_strict=true, bool auto_newline=true) const
severity get_severity() const
bool dont_log(const log_domain &domain) const
Helper class to redirect the output of the logger in a certain scope.
~redirect_output_setter()
std::ostream * old_stream_
The previously set redirection.
redirect_output_setter(std::ostream &stream)
Constructor.
const log_domain & domain_
void do_log_entry(const std::string &str) noexcept
scope_logger(const log_domain &domain, const char *str)
std::chrono::steady_clock::time_point start_
void do_log_exit() noexcept
scope_logger(const log_domain &domain, const std::string &str)
bool get_log_domain_severity(const std::string &name, severity &severity)
std::string list_log_domains(const std::string &filter)
const std::string out_log_file_suffix
void rotate_logs(const std::string &log_dir)
Check how many log files exist and delete the oldest when there's too many.
std::string unique_log_filename()
Generate a unique file name using the current timestamp and a randomly generated number.
void set_log_to_file()
Do the initial redirection to a log file if the logs directory is writable.
void set_log_sanitize(bool sanitize)
toggle log sanitization
utils::optional< bool > log_dir_writable()
Returns the result set by check_log_dir_writable().
void move_log_file()
Move the log file to another directory.
std::string format_timespan(const std::chrono::seconds &span)
TODO: we also have utils::format_timespan, which does something very similar...
std::string sanitize_log(const std::string &logstr)
void check_log_dir_writable()
Checks that a dummy file can be written to and deleted from the logs directory.
std::stringstream & log_to_chat()
Use this to show WML errors in the ingame chat.
const std::string log_file_prefix
std::pair< const std::string, severity > logd
bool is_not_log_file(const std::string &fn)
Use the defined prefix and suffix to determine if a filename is a log file.
void precise_timestamps(bool pt)
bool set_log_domain_severity(const std::string &name, severity severity)
void set_strict_severity(severity severity)
std::string get_log_file_path()
const std::string log_file_suffix
std::ostringstream & operator<<(std::ostringstream &oss, const lg::severity severity)
std::string filename
Filename.