阅读背景:

C++日志模块实现

来源:互联网 



log.h

#ifndef log_H_
#define log_H_
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#include <sys/time.h>
#include "common.h"
#include <iostream>
#include <string>

#define MAX_LOG_MSG_Size 514
#define FileNameSize 50
#define FuncNameSize 30

typedef enum
{
   AllLevel = 0U,
   DEBUG,
   INFO,
   WRAN,
   ERR,
   NoneLevel,
   
}LogLevel;

typedef enum
{
   AllType=0U,
   RUN ,
   USER,
   SYSTEM,
   NoneType,
   
}LogType;

typedef struct LogInfo
{
    char Filename[FileNameSize];
    char FuncName[FuncNameSize];
    int Line;
    int ThreadID;
    struct tm CurTime;
    char LogMsg[MAX_LOG_MSG_Size];
}LogInfoType;
void LOGD(const char *msg);
void logWrite(const char *FileName,const char *FuncName,int Line,int ThreadID,int Type,const char* format,... );

#define Log(Type,format,args...) \
    logWrite( __FILE__,__FUNCTION__ ,__LINE__,pthread_self(),Type,format,##args)



#endif







#ifndef log_H_
#define log_H_



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: