zoukankan      html  css  js  c++  java
  • 简单日志输出管理

    #define SOURCE_FILE_NAME (strrchr((char*)__FILE__, '/') == NULL) ? (char*)__FILE__ : (strrchr((char*)__FILE__, '/') + 1)
    #define LOG_BUF_LEN 1024
    #define LOG_OUT(level, color, msg...)
    do{
    unsigned char logBuf[LOG_BUF_LEN] = {0};
    struct timeval tv;
    gettimeofday(&tv, NULL);
    snprintf(logBuf + strlen(logBuf), LOG_BUF_LEN-strlen(logBuf), "33[1;"color"m");
    snprintf(logBuf + strlen(logBuf), LOG_BUF_LEN-strlen(logBuf), "[%ld.%03ld]:", tv.tv_sec, tv.tv_usec/1000);
    snprintf(logBuf + strlen(logBuf), LOG_BUF_LEN-strlen(logBuf), "[%s]", level);
    snprintf(logBuf + strlen(logBuf), LOG_BUF_LEN-strlen(logBuf), "[%ld]", syscall(SYS_gettid));
    snprintf(logBuf + strlen(logBuf), LOG_BUF_LEN-strlen(logBuf), "[%s|%s|%d]:", SOURCE_FILE_NAME, __FUNCTION__, __LINE__);
    snprintf(logBuf + strlen(logBuf), LOG_BUF_LEN-strlen(logBuf), msg);
    snprintf(logBuf + strlen(logBuf), LOG_BUF_LEN-strlen(logBuf), "33[0m");
    fprintf(stdout, "%s", logBuf);
    }while(0)

  • 相关阅读:
    Repeatable Read
    Read Committed
    Read Uncommitted
    sql 事务
    实用sql语句
    管理mysql
    mysql
    sql delete语句
    sql update语句
    sql INSERT语句
  • 原文地址:https://www.cnblogs.com/mingzhang/p/9666938.html
Copyright © 2011-2022 走看看