+StreamLogOutput stdout_output(std::cout);
+StreamLogOutput stderr_output(std::cerr);
+std::ostream null_stream(NULL);
+
+RawLogBuffer raw_buf;
+
+LogBuffer none_buf(g_logger, LL_NONE);
+LogBuffer error_buf(g_logger, LL_ERROR);
+LogBuffer warning_buf(g_logger, LL_WARNING);
+LogBuffer action_buf(g_logger, LL_ACTION);
+LogBuffer info_buf(g_logger, LL_INFO);
+LogBuffer verbose_buf(g_logger, LL_VERBOSE);
+
+// Connection
+std::ostream *dout_con_ptr = &null_stream;
+std::ostream *derr_con_ptr = &verbosestream;
+
+// Server
+std::ostream *dout_server_ptr = &infostream;
+std::ostream *derr_server_ptr = &errorstream;
+
+#ifndef SERVER
+// Client
+std::ostream *dout_client_ptr = &infostream;
+std::ostream *derr_client_ptr = &errorstream;
+#endif
+
+std::ostream rawstream(&raw_buf);
+std::ostream dstream(&none_buf);
+std::ostream errorstream(&error_buf);
+std::ostream warningstream(&warning_buf);
+std::ostream actionstream(&action_buf);
+std::ostream infostream(&info_buf);
+std::ostream verbosestream(&verbose_buf);
+
+// Android
+#ifdef __ANDROID__
+
+static unsigned int g_level_to_android[] = {
+ ANDROID_LOG_INFO, // LL_NONE
+ //ANDROID_LOG_FATAL,
+ ANDROID_LOG_ERROR, // LL_ERROR
+ ANDROID_LOG_WARN, // LL_WARNING
+ ANDROID_LOG_WARN, // LL_ACTION
+ //ANDROID_LOG_INFO,
+ ANDROID_LOG_DEBUG, // LL_INFO
+ ANDROID_LOG_VERBOSE, // LL_VERBOSE
+};
+
+class AndroidSystemLogOutput : public ICombinedLogOutput {
+ public:
+ AndroidSystemLogOutput()
+ {
+ g_logger.addOutput(this);
+ }
+ ~AndroidSystemLogOutput()
+ {
+ g_logger.removeOutput(this);
+ }
+ void logRaw(LogLevel lev, const std::string &line)
+ {
+ STATIC_ASSERT(ARRLEN(g_level_to_android) == LL_MAX,
+ mismatch_between_android_and_internal_loglevels);
+ __android_log_print(g_level_to_android[lev],
+ PROJECT_NAME_C, "%s", line.c_str());
+ }
+};
+
+AndroidSystemLogOutput g_android_log_output;
+
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
+
+////
+//// Logger
+////
+
+LogLevel Logger::stringToLevel(const std::string &name)