Esempio n. 1
0
Log::Log() : worker(NULL)
{
    SetRealmID(0);
    m_logsTimestamp = "_" + GetTimestampStr();
    LoadFromConfig();
    pandashanLog = fopen("pandashan.log", "a");
}
Esempio n. 2
0
Log::Log() : worker(NULL)
{
    SetRealmID(0);
    m_logsTimestamp = "_" + GetTimestampStr();
    LoadFromConfig();
    pandashanLog = fopen(std::string(m_logsDir).append("pandashan.log").c_str(), "a");
}
Esempio n. 3
0
File: Log.cpp Progetto: imane-jym/gp
void Log::ChangeLogFile(std::string name)
{
	//将旧日志文件改名
	std::string logname = m_logsDir + name;
	std::string storefile = m_logsDir + name + "." + GetTimestampStr(time(NULL) - 24*3600);

	// 移动到其他位置
	rename(logname.c_str(), storefile.c_str());
}
Esempio n. 4
0
void Log::Initialize()
{
    std::string logsDir = sConfig.GetStringDefault("LogsDir","");

    if(!logsDir.empty())
    {
        if((logsDir.at(logsDir.length()-1)!='/') && (logsDir.at(logsDir.length()-1)!='\\'))
            logsDir.append("/");
    }

    std::string logfn=sConfig.GetStringDefault("LogFile", "");
    if(logfn!="")
    {
        if(sConfig.GetIntDefault("LogTimestamp",0))
        {
            std::string logTimestamp = sConfig.GetIntDefault("LogTimestamp",0) ? GetTimestampStr() : "";
            logTimestamp.insert(0,"_");
            size_t dot_pos = logfn.find_last_of(".");
            if(dot_pos!=logfn.npos)
                logfn.insert(dot_pos,logTimestamp);
            else
                logfn += logTimestamp;
        }

        logfile = fopen((logsDir+logfn).c_str(), "w");
    }

    std::string gmlogname = sConfig.GetStringDefault("GMLogFile", "");
    if(gmlogname!="")
    {
        gmLogfile = fopen((logsDir+gmlogname).c_str(), "a");
    }

    std::string dberlogname = sConfig.GetStringDefault("DBErrorLogFile", "");
    if(dberlogname!="")
    {
        dberLogfile = fopen((logsDir+dberlogname).c_str(), "a");
    }
    std::string ralogname = sConfig.GetStringDefault("RaLogFile", "");
    if(ralogname!="")
    {
        raLogfile = fopen((logsDir+ralogname).c_str(), "a");
    }
    m_logLevel     = sConfig.GetIntDefault("LogLevel", 0);
    m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
    InitColors(sConfig.GetStringDefault("LogColors", ""));

    m_logFilter = 0;

    if(sConfig.GetIntDefault("LogFilter_TransportMoves", 0)!=0)
        m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
    if(sConfig.GetIntDefault("LogFilter_CreatureMoves", 0)!=0)
        m_logFilter |= LOG_FILTER_CREATURE_MOVES;
    if(sConfig.GetIntDefault("LogFilter_VisibilityChanges", 0)!=0)
        m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
}
Esempio n. 5
0
void Log::OutPandashan(const char* str, ...)
{
    if (!str)
        return;

    char result[MAX_QUERY_LEN];
    va_list ap;

    va_start(ap, str);
    vsnprintf(result, MAX_QUERY_LEN, str, ap);
    va_end(ap);

    std::string date = GetTimestampStr();
    fprintf(pandashanLog, "[%s] Pandashan LOG : %s\n", date.c_str(), result);
    fflush(pandashanLog);
}
Esempio n. 6
0
void Log::Initialize()
{
    /// Common log files data
    m_logsDir = sConfig.GetStringDefault("LogsDir","");
    if(!m_logsDir.empty())
    {
        if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
            m_logsDir.append("/");
    }

    m_logsTimestamp = "_" + GetTimestampStr();

    /// Open specific log files
    logfile = openLogFile("LogFile","LogTimestamp","w");

    m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
    if(!m_gmlog_per_account)
        gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
    else
    {
        // GM log settings for per account case
        m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
        if(!m_gmlog_filename_format.empty())
        {
            bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp",false);

            size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
            if(dot_pos!=m_gmlog_filename_format.npos)
            {
                if(m_gmlog_timestamp)
                    m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);

                m_gmlog_filename_format.insert(dot_pos,"_#%u");
            }
            else
            {
                m_gmlog_filename_format += "_#%u";

                if(m_gmlog_timestamp)
                    m_gmlog_filename_format += m_logsTimestamp;
            }

            m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
        }
    }

    charLogfile = openLogFile("CharLogFile","CharLogTimestamp","a");
    dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
    raLogfile = openLogFile("RaLogFile",NULL,"a");
    worldLogfile = openLogFile("WorldLogFile","WorldLogTimestamp","a");

    // Main log file settings
    m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
    m_logLevel     = sConfig.GetIntDefault("LogLevel", 0);
    m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
    InitColors(sConfig.GetStringDefault("LogColors", ""));

    m_logFilter = 0;

    if(sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
        m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
    if(sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
        m_logFilter |= LOG_FILTER_CREATURE_MOVES;
    if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
        m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
    if(sConfig.GetBoolDefault("LogFilter_AchievementUpdates", true))
        m_logFilter |= LOG_FILTER_ACHIEVEMENT_UPDATES;

    // Char log settings
    m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false);
}
Esempio n. 7
0
void Log::Initialize()
{
    std::string logsDir = sConfig.GetStringDefault("LogsDir","");

    if(!logsDir.empty())
    {
        if((logsDir.at(logsDir.length()-1)!='/') && (logsDir.at(logsDir.length()-1)!='\\'))
            logsDir.append("/");
    }

    std::string logfn=sConfig.GetStringDefault("LogFile", "");
    if(!logfn.empty())
    {
        if(sConfig.GetBoolDefault("LogTimestamp",false))
        {
            std::string logTimestamp = GetTimestampStr();
            logTimestamp.insert(0,"_");
            size_t dot_pos = logfn.find_last_of(".");
            if(dot_pos!=logfn.npos)
                logfn.insert(dot_pos,logTimestamp);
            else
                logfn += logTimestamp;
        }

        logfile = fopen((logsDir+logfn).c_str(), "w");
    }

    std::string gmlogname = sConfig.GetStringDefault("GMLogFile", "");
    if(!gmlogname.empty())
    {
        if(sConfig.GetBoolDefault("GmLogTimestamp",false))
        {
            std::string gmLogTimestamp = GetTimestampStr();
            gmLogTimestamp.insert(0,"_");
            size_t dot_pos = gmlogname.find_last_of(".");
            if(dot_pos!=gmlogname.npos)
                gmlogname.insert(dot_pos,gmLogTimestamp);
            else
                gmlogname += gmLogTimestamp;
        }
        gmLogfile = fopen((logsDir+gmlogname).c_str(), "a");
    }

    std::string charlogname = sConfig.GetStringDefault("CharLogFile", "");
    if(!charlogname.empty())
    {
        if(sConfig.GetBoolDefault("CharLogTimestamp",false))
        {
            std::string charLogTimestamp = GetTimestampStr();
            charLogTimestamp.insert(0,"_");
            size_t dot_pos = charlogname.find_last_of(".");
            if(dot_pos!=charlogname.npos)
                charlogname.insert(dot_pos,charLogTimestamp);
            else
                charlogname += charLogTimestamp;
        }
        charLogfile = fopen((logsDir+charlogname).c_str(), "a");
    }

    std::string dberlogname = sConfig.GetStringDefault("DBErrorLogFile", "");
    if(!dberlogname.empty())
    {
        dberLogfile = fopen((logsDir+dberlogname).c_str(), "a");
    }
    std::string ralogname = sConfig.GetStringDefault("RaLogFile", "");
    if(!ralogname.empty())
    {
        raLogfile = fopen((logsDir+ralogname).c_str(), "a");
    }
    m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
    m_logLevel     = sConfig.GetIntDefault("LogLevel", 0);
    m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);
    InitColors(sConfig.GetStringDefault("LogColors", ""));

    m_logFilter = 0;

    if(sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
        m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
    if(sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
        m_logFilter |= LOG_FILTER_CREATURE_MOVES;
    if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
        m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;

    m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false);
}
Esempio n. 8
0
Log::Log() : AppenderId(0), lowestLogLevel(LOG_LEVEL_FATAL), _ioService(nullptr), _strand(nullptr)
{
    m_logsTimestamp = "_" + GetTimestampStr();
    RegisterAppender<AppenderConsole>();
    RegisterAppender<AppenderFile>();
}
Esempio n. 9
0
Log::Log() : worker(NULL)
{
    SetRealmID(0);
    m_logsTimestamp = "_" + GetTimestampStr();
    LoadFromConfig();
}
Esempio n. 10
0
void Log::Initialize()
{
    // Common log files data
    m_logsDir = sConfig.GetStringDefault("LogsDir", "0 6 4 3 1 1 2 7 5 0 4 0 1 3 2 4 0");
    if (!m_logsDir.empty())
        if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
            m_logsDir.append("/");

    m_logsTimestamp = "_" + GetTimestampStr();

    // Open specific log files
    FILE* logfile = openLogFile("LogFile", "LogTimestamp", "wb");

    for (int i = 0; i < MAX_LOG_TYPES; ++i)
        if (!m_logFiles[i])
            m_logFiles[i] = logfile;

    InitColors(sConfig.GetStringDefault("LogColors", "0 6 4 3 1 1 2 7 5 0 4 0 1 3 2 4 0"));

    m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount", false);
    if (!m_gmlog_per_account)
        m_logFiles[LOG_TYPE_COMMAND] = openLogFile("GMLogFile", "GmLogTimestamp", "ab");
    else
    {
        // GM log settings for per account case
        m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", "");
        if (!m_gmlog_filename_format.empty())
        {
            bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp", false);

            size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
            if (dot_pos != m_gmlog_filename_format.npos)
            {
                if (m_gmlog_timestamp)
                    m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp);

                m_gmlog_filename_format.insert(dot_pos, "_#%u");
            }
            else
            {
                m_gmlog_filename_format += "_#%u";

                if (m_gmlog_timestamp)
                    m_gmlog_filename_format += m_logsTimestamp;
            }

            m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
        }
    }

    m_logFiles[LOG_TYPE_CHAR]     = openLogFile("CharLogFile", "CharLogTimestamp", "ab");
    m_logFiles[LOG_TYPE_ERROR_DB] = openLogFile("DBErrorLogFile", NULL, "ab");
    m_logFiles[LOG_TYPE_REMOTE]   = openLogFile("RaLogFile", NULL, "ab");
    m_logFiles[LOG_TYPE_CHAT]     = openLogFile("ChatLogFile", "ChatLogTimestamp", "ab");
    m_logFiles[LOG_TYPE_ARENA]    = openLogFile("ArenaLogFile", NULL, "ab");
    m_logFiles[LOG_TYPE_WARDEN]   = openLogFile("Warden.LogFile", NULL, "ab");
    m_logFiles[LOG_TYPE_NETWORK]  = openLogFile("WorldLogFile", NULL, "ab");
    m_logFiles[LOG_TYPE_SQL]      = openLogFile("LogSQLFilename", "LogSQLTimestamp", "ab");

    m_logMask = sConfig.GetIntDefault("LogMask", 51);
    m_logMaskDatabase = sConfig.GetIntDefault("DBLogMask", 0);

    // -------------------------------------------------------------------
    // Deprecated, kept for backward compatibilty - @todo remove in future
    // -------------------------------------------------------------------

    // Main log file settings
    switch (sConfig.GetIntDefault("LogLevel", -1))
    {
        case LOGL_MINIMAL:
            m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            break;
        case LOGL_BASIC:
            m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            m_logMask |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
            break;
        case LOGL_DETAIL:
            m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            m_logMask |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
            m_logMask |= LOGL_BASIC | LOG_TYPE_DETAIL | LOG_TYPE_SQL | LOG_TYPE_REMOTE | LOG_TYPE_CHAR;
            break;
        case LOGL_DEBUG:
            m_logMask = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            m_logMask |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
            m_logMask |= LOGL_BASIC | LOG_TYPE_DETAIL | LOG_TYPE_SQL | LOG_TYPE_REMOTE | LOG_TYPE_CHAR;
            m_logMask |= LOGL_DETAIL | LOG_TYPE_DEBUG | LOG_TYPE_MAP | LOG_TYPE_VMAP | LOG_TYPE_MMAP | LOG_TYPE_WARDEN | LOG_TYPE_ARENA | LOG_TYPE_NETWORK;
            break;
        case -1:
            break;
    }

    switch (sConfig.GetIntDefault("DBLogLevel", -1))
    {
        case LOGL_MINIMAL:
            m_logMaskDatabase = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            break;
        case LOGL_BASIC:
            m_logMaskDatabase = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            m_logMaskDatabase |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
            break;
        case LOGL_DETAIL:
            m_logMaskDatabase = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            m_logMaskDatabase |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
            m_logMaskDatabase |= LOGL_BASIC | LOG_TYPE_DETAIL | LOG_TYPE_SQL | LOG_TYPE_REMOTE | LOG_TYPE_CHAR;
            break;
        case LOGL_DEBUG:
            m_logMaskDatabase = LOG_TYPE_STRING | LOG_TYPE_COMMAND | LOG_TYPE_ERROR | LOG_TYPE_ERROR_DB;
            m_logMaskDatabase |= LOG_TYPE_BASIC | LOG_TYPE_WARDEN;
            m_logMaskDatabase |= LOGL_BASIC | LOG_TYPE_DETAIL | LOG_TYPE_SQL | LOG_TYPE_REMOTE | LOG_TYPE_CHAR;
            m_logMaskDatabase |= LOGL_DETAIL | LOG_TYPE_DEBUG | LOG_TYPE_MAP | LOG_TYPE_VMAP | LOG_TYPE_MMAP | LOG_TYPE_WARDEN | LOG_TYPE_ARENA | LOG_TYPE_NETWORK;
            break;
        case -1:
            break;
    }

    // Check whether we'll log GM commands/RA events/character outputs/chat stuffs
    m_logMaskDatabase |= static_cast<unsigned char>(sConfig.GetBoolDefault("LogDB.Char", false)) << LOG_TYPE_CHAR;
    m_logMaskDatabase |= static_cast<unsigned char>(sConfig.GetBoolDefault("LogDB.RA",   false)) << LOG_TYPE_REMOTE;
    m_logMaskDatabase |= static_cast<unsigned char>(sConfig.GetBoolDefault("LogDB.GM",   false)) << LOG_TYPE_COMMAND;
    m_logMaskDatabase |= static_cast<unsigned char>(sConfig.GetBoolDefault("LogDB.Chat", false)) << LOG_TYPE_CHAT;
}
Esempio n. 11
0
Log::Log() : _ioService(nullptr), _strand(nullptr)
{
    m_logsTimestamp = "_" + GetTimestampStr();
    RegisterAppender<AppenderConsole>();
    RegisterAppender<AppenderFile>();
}
Esempio n. 12
0
void Log::Initialize()
{
    /// Check whether we'll log GM commands/RA events/character outputs/chat stuffs
    m_dbChar = sConfig->GetBoolDefault("LogDB.Char", false);
    m_dbRA = sConfig->GetBoolDefault("LogDB.RA", false);
    m_dbGM = sConfig->GetBoolDefault("LogDB.GM", false);
    m_dbChat = sConfig->GetBoolDefault("LogDB.Chat", false);

    /// Realm must be 0 by default
    SetRealmID(0);

    /// Common log files data
    m_logsDir = sConfig->GetStringDefault("LogsDir","");
    if (!m_logsDir.empty())
        if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
            m_logsDir.append("/");

    m_logsTimestamp = "_" + GetTimestampStr();

    /// Open specific log files
    logfile = openLogFile("LogFile","LogTimestamp","w");
    InitColors(sConfig->GetStringDefault("LogColors", ""));

    m_gmlog_per_account = sConfig->GetBoolDefault("GmLogPerAccount",false);
    if(!m_gmlog_per_account)
        gmLogfile = openLogFile("GMLogFile","GmLogTimestamp","a");
    else
    {
        // GM log settings for per account case
        m_gmlog_filename_format = sConfig->GetStringDefault("GMLogFile", "");
        if(!m_gmlog_filename_format.empty())
        {
            bool m_gmlog_timestamp = sConfig->GetBoolDefault("GmLogTimestamp",false);

            size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
            if(dot_pos!=m_gmlog_filename_format.npos)
            {
                if(m_gmlog_timestamp)
                    m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);

                m_gmlog_filename_format.insert(dot_pos,"_#%u");
            }
            else
            {
                m_gmlog_filename_format += "_#%u";

                if(m_gmlog_timestamp)
                    m_gmlog_filename_format += m_logsTimestamp;
            }

            m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
        }
    }

    charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
    dberLogfile = openLogFile("DBErrorLogFile", NULL, "a");
    raLogfile = openLogFile("RaLogFile", NULL, "a");
    chatLogfile = openLogFile("ChatLogFile", "ChatLogTimestamp", "a");
    arenaLogFile = openLogFile("ArenaLogFile", NULL,"a");
    sqlLogFile = openLogFile("SQLDriverLogFile", NULL, "a");

    // Main log file settings
    m_logLevel     = sConfig->GetIntDefault("LogLevel", LOGL_NORMAL);
    m_logFileLevel = sConfig->GetIntDefault("LogFileLevel", LOGL_NORMAL);
    m_dbLogLevel   = sConfig->GetIntDefault("DBLogLevel", LOGL_NORMAL);
    m_sqlDriverQueryLogging  = sConfig->GetBoolDefault("SQLDriverQueryLogging", false);

    m_logFilter = 0;

    if(sConfig->GetBoolDefault("LogFilter_TransportMoves", true))
        m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
    if(sConfig->GetBoolDefault("LogFilter_CreatureMoves", true))
        m_logFilter |= LOG_FILTER_CREATURE_MOVES;
    if(sConfig->GetBoolDefault("LogFilter_VisibilityChanges", true))
        m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;
    if(sConfig->GetBoolDefault("LogFilter_AchievementUpdates", true))
        m_logFilter |= LOG_FILTER_ACHIEVEMENT_UPDATES;

    // Char log settings
    m_charLog_Dump = sConfig->GetBoolDefault("CharLogDump", false);
    m_charLog_Dump_Separate = sConfig->GetBoolDefault("CharLogDump.Separate", false);
    if (m_charLog_Dump_Separate)
    {
        m_dumpsDir = sConfig->GetStringDefault("CharLogDump.SeparateDir", "");
        if (!m_dumpsDir.empty())
            if ((m_dumpsDir.at(m_dumpsDir.length() - 1) != '/') && (m_dumpsDir.at(m_dumpsDir.length() - 1) != '\\'))
                m_dumpsDir.append("/");
    }
}
Esempio n. 13
0
void Log::Initialize()
{
    /// Common log files data
    m_logsDir = sConfig.GetStringDefault("LogsDir","");
    if(!m_logsDir.empty())
    {
        if((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\'))
            m_logsDir.append("/");
    }

    m_logsTimestamp = "_" + GetTimestampStr();

    /// Open specific log files
    m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false);
    if(!m_gmlog_per_account)
        logFile[LOG_GM] = openLogFile(LOG_GM);
    else
    {
        // GM log settings for per account case
        m_gmlog_filename_format =  sConfig.GetStringDefault(logToStr[LOG_GM][0],"gm_commands.log");
        if(!m_gmlog_filename_format.empty())
        {
            bool m_gmlog_timestamp = sConfig.GetBoolDefault(logToStr[LOG_GM][2],false);

            size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
            if(dot_pos!=m_gmlog_filename_format.npos)
            {
                if(m_gmlog_timestamp)
                    m_gmlog_filename_format.insert(dot_pos,m_logsTimestamp);

                m_gmlog_filename_format.insert(dot_pos,"_%u");
            }
            else
            {
                m_gmlog_filename_format += "__%u";

                if(m_gmlog_timestamp)
                    m_gmlog_filename_format += m_logsTimestamp;
            }

            m_gmlog_filename_format = (m_logsDir.empty() ? "" : m_logsDir + m_gmlog_filename_format);
        }
    }

    m_whisplog_filename_format = (m_logsDir.empty() ? "." : m_logsDir) + sConfig.GetStringDefault("WhispLogDir", "whisps/") + "whisp_%u_.log";

    for (uint8 i = LOG_DEFAULT; i < LOG_MAX_FILES; ++i)
        logFile[i] = openLogFile(LogNames(i));

    // Main log file settings
    m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
    m_logFileLevel = sConfig.GetIntDefault("LogFileLevel", 0);

    m_logFilter = 0;

    if(sConfig.GetBoolDefault("LogFilter_TransportMoves", true))
        m_logFilter |= LOG_FILTER_TRANSPORT_MOVES;
    if(sConfig.GetBoolDefault("LogFilter_CreatureMoves", true))
        m_logFilter |= LOG_FILTER_CREATURE_MOVES;
    if(sConfig.GetBoolDefault("LogFilter_VisibilityChanges", true))
        m_logFilter |= LOG_FILTER_VISIBILITY_CHANGES;

}
Esempio n. 14
0
Log::Log() : worker(NULL)
{
    m_logsTimestamp = "_" + GetTimestampStr();
    LoadFromConfig();
}
Esempio n. 15
0
void Log::Initialize()
{
    /// Check whether we'll log GM commands/RA events/character outputs/chat stuffs
    m_dbChar = sConfig->GetBoolDefault("LogDB.Char", false);
    m_dbRA = sConfig->GetBoolDefault("LogDB.RA", false);
    m_dbGM = sConfig->GetBoolDefault("LogDB.GM", false);
    m_dbChat = sConfig->GetBoolDefault("LogDB.Chat", false);

    /// Realm must be 0 by default
    SetRealmID(0);

    /// Common log files data
    m_logsDir = sConfig->GetStringDefault("LogsDir", "");
    if(!m_logsDir.empty())
        if((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
            m_logsDir.append("/");

    m_logsTimestamp = "_" + GetTimestampStr();

    /// Open specific log files
    logfile = openLogFile("LogFile", "LogTimestamp", "w");
    InitColors(sConfig->GetStringDefault("LogColors", ""));

    m_gmlog_per_account = sConfig->GetBoolDefault("GmLogPerAccount", false);
    if(!m_gmlog_per_account)
        gmLogfile = openLogFile("GMLogFile", "GmLogTimestamp", "a");
    else
    {
        // GM log settings for per account case
        m_gmlog_filename_format = sConfig->GetStringDefault("GMLogFile", "");
        if(!m_gmlog_filename_format.empty())
        {
            bool m_gmlog_timestamp = sConfig->GetBoolDefault("GmLogTimestamp", false);

            size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
            if(dot_pos!=m_gmlog_filename_format.npos)
            {
                if(m_gmlog_timestamp)
                    m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp);

                m_gmlog_filename_format.insert(dot_pos, "_#%u");
            }
            else
            {
                m_gmlog_filename_format += "_#%u";

                if(m_gmlog_timestamp)
                    m_gmlog_filename_format += m_logsTimestamp;
            }

            m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
        }
    }

    charLogfile     = openLogFile("CharLogFile", "CharLogTimestamp", "a");
    dberLogfile     = openLogFile("DBErrorLogFile", NULL, "a");
    raLogfile       = openLogFile("RASOAP", NULL, "a");
    chatLogfile     = openLogFile("ChatLogFile", "ChatLogTimestamp", "a");
    arenaLogFile    = openLogFile("ArenaLogFile", NULL, "a");
    sqlLogFile      = openLogFile("SQLDriverLogFile", NULL, "a");
    sqlDevLogFile   = openLogFile("SQLDeveloperLogFile", NULL, "a");
    wardenLogFile   = openLogFile("WardenLogFile", NULL, "a");

    // Main log file settings
    m_logLevel     = sConfig->GetIntDefault("LogLevel", LOGL_NORMAL);
    m_logFileLevel = sConfig->GetIntDefault("LogFileLevel", LOGL_NORMAL);
    m_dbLogLevel   = sConfig->GetIntDefault("DBLogLevel", LOGL_NORMAL);
    m_sqlDriverQueryLogging  = sConfig->GetBoolDefault("SQLDriverQueryLogging", false);

    m_DebugLogMask = DebugLogFilters(sConfig->GetIntDefault("DebugLogMask", LOG_FILTER_NONE));

    // Char log settings
    m_charLog_Dump = sConfig->GetBoolDefault("CharLogDump", false);
    m_charLog_Dump_Separate = sConfig->GetBoolDefault("CharLogDump.Separate", false);
    if(m_charLog_Dump_Separate)
    {
        m_dumpsDir = sConfig->GetStringDefault("CharLogDump.SeparateDir", "");
        if(!m_dumpsDir.empty())
            if((m_dumpsDir.at(m_dumpsDir.length() - 1) != '/') && (m_dumpsDir.at(m_dumpsDir.length() - 1) != '\\'))
                m_dumpsDir.append("/");
    }
}
Esempio n. 16
0
void Log::Initialize()
{
    /// Common log files data
    m_logsDir = sConfig.GetStringDefault("LogsDir");
    if (!m_logsDir.empty())
    {
        if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
            m_logsDir.append("/");
    }

    m_logsTimestamp = "_" + GetTimestampStr();

    /// Open specific log files
    logfile = openLogFile("LogFile", "LogTimestamp", "w");

    m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount", false);
    if (!m_gmlog_per_account)
        gmLogfile = openLogFile("GMLogFile", "GmLogTimestamp", "a");
    else
    {
        // GM log settings for per account case
        m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile");
        if (!m_gmlog_filename_format.empty())
        {
            bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp", false);

            size_t dot_pos = m_gmlog_filename_format.find_last_of(".");
            if (dot_pos != m_gmlog_filename_format.npos)
            {
                if (m_gmlog_timestamp)
                    m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp);

                m_gmlog_filename_format.insert(dot_pos, "_#%u");
            }
            else
            {
                m_gmlog_filename_format += "_#%u";

                if (m_gmlog_timestamp)
                    m_gmlog_filename_format += m_logsTimestamp;
            }

            m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format;
        }
    }

    charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
    dberLogfile = openLogFile("DBErrorLogFile", nullptr, "a");
    elunaErrLogfile = openLogFile("ElunaErrorLogFile", nullptr, "a");
    eventAiErLogfile = openLogFile("EventAIErrorLogFile", nullptr, "a");
    raLogfile = openLogFile("RaLogFile", nullptr, "a");
    worldLogfile = openLogFile("WorldLogFile", "WorldLogTimestamp", "a");

    // Main log file settings
    m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
    m_logLevel     = LogLevel(sConfig.GetIntDefault("LogLevel", 0));
    m_logFileLevel = LogLevel(sConfig.GetIntDefault("LogFileLevel", 0));
    InitColors(sConfig.GetStringDefault("LogColors"));

    m_logFilter = 0;
    for (int i = 0; i < LOG_FILTER_COUNT; ++i)
        if (*logFilterData[i].name)
            if (sConfig.GetBoolDefault(logFilterData[i].configName, logFilterData[i].defaultState))
                m_logFilter |= (1 << i);

    // Char log settings
    m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false);
}
Esempio n. 17
0
Log::Log() : _ioService(nullptr), _strand(nullptr)
{
    m_logsTimestamp = "_" + GetTimestampStr();
    LoadFromConfig();
}