added prefix LOG_ to loglevel

This commit is contained in:
Koncord 2016-08-15 21:33:18 +08:00
parent 170455e08a
commit 8d88381dac
4 changed files with 17 additions and 17 deletions

View file

@ -58,13 +58,13 @@ void Log::print(int level, const char *file, int line, const char *message, ...)
str += "["; str += "[";
switch(level) switch(level)
{ {
case WARNING: case LOG_WARN:
str += "WARN"; str += "WARN";
break; break;
case ERROR: case LOG_ERROR:
str += "ERR"; str += "ERR";
break; break;
case FATAL: case LOG_FATAL:
str += "FATAL"; str += "FATAL";
break; break;
default: default:

View file

@ -22,10 +22,10 @@ class Log
public: public:
enum enum
{ {
INFO = 0, LOG_INFO = 0,
WARNING, LOG_WARN,
ERROR, LOG_ERROR,
FATAL, LOG_FATAL,
}; };
static void Create(int logLevel); static void Create(int logLevel);
static void Delete(); static void Delete();

View file

@ -93,18 +93,18 @@ RakNet::RakString MasterClient::Send(std::string motd, unsigned players, unsigne
// then Receive(), then HasFailedConnectionAttempt(),HasLostConnection() // then Receive(), then HasFailedConnectionAttempt(),HasLostConnection()
sa = tcpInterface.HasCompletedConnectionAttempt(); sa = tcpInterface.HasCompletedConnectionAttempt();
if (sa != RakNet::UNASSIGNED_SYSTEM_ADDRESS) if (sa != RakNet::UNASSIGNED_SYSTEM_ADDRESS)
LOG_MESSAGE_SIMPLE(Log::INFO, "Connected to master server: %s", sa.ToString()); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Connected to master server: %s", sa.ToString());
sa = tcpInterface.HasFailedConnectionAttempt(); sa = tcpInterface.HasFailedConnectionAttempt();
if (sa != RakNet::UNASSIGNED_SYSTEM_ADDRESS) if (sa != RakNet::UNASSIGNED_SYSTEM_ADDRESS)
{ {
LOG_MESSAGE_SIMPLE(Log::WARNING, "Failed to connect to master server: %s", sa.ToString()); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Failed to connect to master server: %s", sa.ToString());
return "FAIL_CONNECT"; return "FAIL_CONNECT";
} }
sa = tcpInterface.HasLostConnection(); sa = tcpInterface.HasLostConnection();
if (sa != RakNet::UNASSIGNED_SYSTEM_ADDRESS) if (sa != RakNet::UNASSIGNED_SYSTEM_ADDRESS)
{ {
LOG_MESSAGE_SIMPLE(Log::WARNING, "Lost connection to master server: %s", sa.ToString()); LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Lost connection to master server: %s", sa.ToString());
return "LOST_CONNECTION"; return "LOST_CONNECTION";
} }
@ -132,12 +132,12 @@ void MasterClient::Update()
while (sRun) while (sRun)
{ {
if (response == "Created") if (response == "Created")
LOG_MESSAGE_SIMPLE(Log::INFO, "Server registered on the master server.", ""); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server registered on the master server.", "");
else if (response == "Accepted") else if (response == "Accepted")
LOG_MESSAGE_SIMPLE(Log::INFO, "Server updated information about himself on the master server.", ""); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server updated information about himself on the master server.", "");
else if (response == "bad request") else if (response == "bad request")
{ {
LOG_MESSAGE_SIMPLE(Log::WARNING, "Update rate is too low, and the master server has deleted information about" LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Update rate is too low, and the master server has deleted information about"
" the server. Trying low rate...", ""); " the server. Trying low rate...", "");
SetUpdateRate(timeout - step_rate); SetUpdateRate(timeout - step_rate);
update = false; update = false;

View file

@ -78,8 +78,8 @@ int main(int argc, char *argv[])
loadSettings(mgr); loadSettings(mgr);
int logLevel = mgr.getInt("loglevel", "General"); int logLevel = mgr.getInt("loglevel", "General");
if(logLevel < Log::INFO || logLevel > Log::FATAL) if(logLevel < Log::LOG_INFO || logLevel > Log::LOG_FATAL)
logLevel = Log::INFO; logLevel = Log::LOG_INFO;
LOG_INIT(logLevel); LOG_INIT(logLevel);
int players = mgr.getInt("players", "General"); int players = mgr.getInt("players", "General");
@ -120,7 +120,7 @@ int main(int argc, char *argv[])
MasterClient *mclient; MasterClient *mclient;
if(masterEnabled) if(masterEnabled)
{ {
LOG_MESSAGE_SIMPLE(Log::INFO, "%s", "Sharing server query info to master enabled."); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Sharing server query info to master enabled.");
string masterAddr = mgr.getString("address", "MasterServer"); string masterAddr = mgr.getString("address", "MasterServer");
int masterPort = mgr.getInt("port", "MasterServer"); int masterPort = mgr.getInt("port", "MasterServer");
mclient = new MasterClient(masterAddr, (unsigned short) masterPort, addr, (unsigned short) port); mclient = new MasterClient(masterAddr, (unsigned short) masterPort, addr, (unsigned short) port);
@ -142,7 +142,7 @@ int main(int argc, char *argv[])
} }
if (code == 0) if (code == 0)
LOG_MESSAGE_SIMPLE(Log::INFO, "%s", "Quitting peacefully."); LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "%s", "Quitting peacefully.");
LOG_QUIT(); LOG_QUIT();
return code; return code;