Fix mobile STK server logging

This commit is contained in:
Benau 2020-02-28 19:53:01 +08:00
parent f37a5ee5d3
commit f590280431
2 changed files with 10 additions and 6 deletions

View File

@ -59,7 +59,7 @@ private:
/** The singleton instance. */
static NetworkConfig *m_network_config[PT_COUNT];
enum NetworkType
enum NetworkType : int
{
NETWORK_NONE, NETWORK_WAN, NETWORK_LAN
};
@ -67,7 +67,7 @@ private:
std::atomic<IPType> m_ip_type;
/** Keeps the type of network connection: none (yet), LAN or WAN. */
NetworkType m_network_type;
std::atomic<NetworkType> m_network_type;
/** If set it allows clients to connect directly to this server without
* using the stk server in between. It requires obviously that this
@ -75,7 +75,7 @@ private:
bool m_is_public_server;
/** True if this host is a server, false otherwise. */
bool m_is_server;
std::atomic_bool m_is_server;
/** True if a client should connect to the first server it finds and
* immediately start a race. */

View File

@ -173,16 +173,20 @@ void Log::printMessage(int level, const char *component, const char *format,
remaining = MAX_LENGTH - index > 0 ? MAX_LENGTH - index : 0;
}
#ifndef ANDROID
#ifdef MOBILE_STK
// Mobile STK already has timestamp logging in console
std::string server_prefix = "Server";
#else
std::string server_prefix = StkTime::getLogTime();
#endif
if (NetworkConfig::get()->isNetworking() &&
NetworkConfig::get()->isServer())
{
index += snprintf (line + index, remaining,
"%s [%s] %s: ", StkTime::getLogTime().c_str(),
"%s [%s] %s: ", server_prefix.c_str(),
names[level], component);
}
else
#endif
{
index += snprintf (line + index, remaining,
"[%s] %s: ", names[level], component);