예제 #1
0
파일: Log.cpp 프로젝트: Aincent/server
void Log::outError(const char* err, ...)
{
    if (!err)
        { return; }

    if (m_colored)
        { SetColor(false, m_colors[LogError]); }

    if (m_includeTime)
        { outTime(); }

    va_list ap;

    va_start(ap, err);
    vutf8printf(stderr, err, &ap);
    va_end(ap);

    if (m_colored)
        { ResetColor(false); }

    fprintf(stderr, "\n");
    if (logfile)
    {
        outTimestamp(logfile);
        fprintf(logfile, "ERROR:");

        va_start(ap, err);
        vfprintf(logfile, err, ap);
        va_end(ap);

        fprintf(logfile, "\n");
        fflush(logfile);
    }

    fflush(stderr);
}
예제 #2
0
파일: Log.cpp 프로젝트: Aincent/server
void Log::outString(const char* str, ...)
{
    if (!str)
        { return; }

    if (m_colored)
        { SetColor(true, m_colors[LogNormal]); }

    if (m_includeTime)
        { outTime(); }

    va_list ap;

    va_start(ap, str);
    vutf8printf(stdout, str, &ap);
    va_end(ap);

    if (m_colored)
        { ResetColor(true); }

    printf("\n");

    if (logfile)
    {
        outTimestamp(logfile);

        va_start(ap, str);
        vfprintf(logfile, str, ap);
        fprintf(logfile, "\n");
        va_end(ap);

        fflush(logfile);
    }

    fflush(stdout);
}
예제 #3
0
파일: Log.cpp 프로젝트: boom8866/new
void Log::outDebugInLine(const char * str, ...)
{
    if (!str)
        return;

    if (m_logLevel > LOGL_DETAIL)
    {
        va_list ap;
        va_start(ap, str);
        vutf8printf(stdout, str, &ap);
        va_end(ap);

        //if (m_colored)
        //    ResetColor(true);

        if (logfile)
        {
            va_list ap2;
            va_start(ap2, str);
            vfprintf(logfile, str, ap2);
            va_end(ap2);
        }
    }
}
예제 #4
0
void Log::outCommand(uint32 account, const char* str, ...)
{
    if (!str)
        return;

    std::lock_guard<std::mutex> guard(m_worldLogMtx);
    if (m_logLevel >= LOG_LVL_DETAIL)
    {
        if (m_colored)
            SetColor(true, m_colors[LogDetails]);

        if (m_includeTime)
            outTime();

        va_list ap;
        va_start(ap, str);
        vutf8printf(stdout, str, &ap);
        va_end(ap);

        if (m_colored)
            ResetColor(true);

        printf("\n");
    }

    if (logfile && m_logFileLevel >= LOG_LVL_DETAIL)
    {
        va_list ap;
        outTimestamp(logfile);
        va_start(ap, str);
        vfprintf(logfile, str, ap);
        fprintf(logfile, "\n");
        va_end(ap);
        fflush(logfile);
    }

    if (m_gmlog_per_account)
    {
        if (FILE* per_file = openGmlogPerAccount(account))
        {
            va_list ap;
            outTimestamp(per_file);
            va_start(ap, str);
            vfprintf(per_file, str, ap);
            fprintf(per_file, "\n");
            va_end(ap);
            fclose(per_file);
        }
    }
    else if (gmLogfile)
    {
        va_list ap;
        outTimestamp(gmLogfile);
        va_start(ap, str);
        vfprintf(gmLogfile, str, ap);
        fprintf(gmLogfile, "\n");
        va_end(ap);
        fflush(gmLogfile);
    }

    fflush(stdout);
}
예제 #5
0
파일: Log.cpp 프로젝트: GlassFace/MythCore
void Log::outCommand(uint32 account, const char * str, ...)
{
    if(!str)
        return;

    // TODO: support accountid
    if(m_enableLogDB && m_dbGM)
    {
        va_list ap2;
        va_start(ap2, str);
        char nnew_str[MAX_QUERY_LEN];
        vsnprintf(nnew_str, MAX_QUERY_LEN, str, ap2);
        outDB(LOG_TYPE_GM, nnew_str);
        va_end(ap2);
    }

    if(m_logLevel > LOGL_NORMAL)
    {
        if(m_colored)
            SetColor(true, m_colors[LOGL_BASIC]);

        va_list ap;
        va_start(ap, str);
        vutf8printf(stdout, str, &ap);
        va_end(ap);

        if(m_colored)
            ResetColor(true);

        printf("\n");

        if(logfile)
        {
            outTimestamp(logfile);
            va_list ap;
            va_start(ap, str);
            vfprintf(logfile, str, ap);
            fprintf(logfile, "\n" );
            va_end(ap);
            fflush(logfile);
        }
    }

    if(m_gmlog_per_account)
    {
        if(FILE* per_file = openGmlogPerAccount (account))
        {
            outTimestamp(per_file);
            va_list ap;
            va_start(ap, str);
            vfprintf(per_file, str, ap);
            fprintf(per_file, "\n" );
            va_end(ap);
            fclose(per_file);
        }
    }
    else if(gmLogfile)
    {
        outTimestamp(gmLogfile);
        va_list ap;
        va_start(ap, str);
        vfprintf(gmLogfile, str, ap);
        fprintf(gmLogfile, "\n" );
        va_end(ap);
        fflush(gmLogfile);
    }

    fflush(stdout);
}
예제 #6
0
파일: Util.cpp 프로젝트: BoThay/ArkCORE
void utf8printf(FILE *out, const char *str, ...) {
    va_list ap;
    va_start(ap, str);
    vutf8printf(out, str, &ap);
    va_end(ap);
}