#pragma once #include #include #include #include #include #include #include #ifdef __ANDROID__ #include #endif namespace Looper::Log { struct LogStream { std::set outputs; static std::set global_outputs; int my_log_level; std::set streams; bool nested; bool need_prefix; std::vector names; std::set get_used_outputs(); #ifdef __ANDROID__ std::string line; std::set android_outputs; #endif LogStream(std::initializer_list names, int log_level, bool nested, void* discriminator); public: static int log_level; void writeprefix(); void writeln(const char *msg); void writeln_n(const char *msg, size_t n); void writeln(std::string msg); void writes(const char *msg); void writesn(const char *msg, size_t n); void writes(std::string msg); void writec(const char chr); void vwritef(const char *fmt, va_list args); void writef(const char *fmt, ...); void vwritefln(const char *fmt, va_list args); void writefln(const char *fmt, ...); LogStream(std::initializer_list names, std::initializer_list streams, int log_level = 0); #ifdef __ANDROID__ LogStream(std::initializer_list names, std::initializer_list> outputs, int log_level = 0); #else LogStream(std::initializer_list names, std::initializer_list outputs, int log_level = 0); #endif }; void init_logging(); LogStream &get_log_stream_by_level(int level); #define DEBUG (Looper::Log::get_log_stream_by_level(-1)) #define INFO (Looper::Log::get_log_stream_by_level(0)) #define WARNING (Looper::Log::get_log_stream_by_level(1)) #define ERROR (Looper::Log::get_log_stream_by_level(2)) }