Example #1
0
bool mtc_msg(const char *func, const char *file, long line,
             int level, const char *format, ...)
{
    //int dftlv = hdf_get_int_value(g_cfg, PRE_CONFIG".trace_level", TC_DEFAULT_LEVEL);
    if (level > m_dftlv) return false;
    
    if (g_fp == NULL) return false;

    va_list ap;
    char tm[25] = {0};
    double usec = ne_timef();
    time_t sec = (time_t)usec;
    //mutil_getdatetime(tm, sizeof(tm), "%Y-%m-%d %H:%M:%S", time(NULL));
    struct tm *stm = localtime(&sec);
    strftime(tm, 25, "%Y-%m-%d %H:%M:%S", stm);
    tm[24] = '\0';

    fprintf(g_fp, "[%s %f]", tm, usec);
    fprintf(g_fp, "[%s]", g_trace_level[level]);
    fprintf(g_fp, "[%s:%li %s] ", file, line, func);

    va_start(ap, (void*)format);
    vfprintf(g_fp, format, ap);
    va_end(ap);

    fprintf(g_fp, "\n");

    trace_shift_file();
    return true;
}
Example #2
0
bool mtc_msg(const char *func, const char *file, long line,
             int level, const char *format, ...)
{
    int dftlv = hdf_get_int_value(g_cfg, PRE_CONFIG".trace_level", TC_DEFAULT_LEVEL);
    if (level > dftlv)
        return true;
    
    if (g_fp == NULL)
        return false;

    va_list ap;
    char tm[LEN_TM];
    mutil_getdatetime(tm, sizeof(tm), "%Y-%m-%d %H:%M:%S", time(NULL));

    fprintf(g_fp, "[%s]", tm);
    fprintf(g_fp, "[%s]", g_trace_level[level]);
    fprintf(g_fp, "[%s:%li %s] ", file, line, func);

    va_start(ap, (void*)format);
    vfprintf(g_fp, format, ap);
    va_end(ap);

    fprintf(g_fp, "\n");

    trace_shift_file();
    return true;
}