More verbose logging for the server.
This commit is contained in:
@@ -39,14 +39,16 @@ using namespace boost::posix_time;
|
||||
#define SERVER_MSG_LOG_FILE_NAME "server_messages.log"
|
||||
|
||||
static string g_logFile;
|
||||
static int g_logLevel = 1;
|
||||
|
||||
void
|
||||
loghelper_init(const string &logDir)
|
||||
loghelper_init(const string &logDir, int logLevel)
|
||||
{
|
||||
path tmpLogFile(logDir);
|
||||
tmpLogFile /= SERVER_MSG_LOG_FILE_NAME;
|
||||
|
||||
g_logFile = tmpLogFile.directory_string();
|
||||
g_logLevel = logLevel;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -63,11 +65,28 @@ internal_log_err(const string &msg)
|
||||
void
|
||||
internal_log_msg(const std::string &msg)
|
||||
{
|
||||
if (!g_logFile.empty())
|
||||
if (g_logLevel)
|
||||
{
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
o << second_clock::local_time() << " MSG: " << msg;
|
||||
if (!g_logFile.empty())
|
||||
{
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
o << second_clock::local_time() << " MSG: " << msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
internal_log_level(const std::string &msg, int logLevel)
|
||||
{
|
||||
if (g_logLevel >= logLevel)
|
||||
{
|
||||
if (!g_logFile.empty())
|
||||
{
|
||||
ofstream o(g_logFile.c_str(), ios_base::out | ios_base::app);
|
||||
if (!o.fail())
|
||||
o << second_clock::local_time() << " OUT: " << msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user