stdafx.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // stdafx.h : 标准系统包含文件的包含文件,
  2. // 或是常用但不常更改的项目特定的包含文件
  3. //
  4. #pragma once
  5. #include <iostream>
  6. #include <tchar.h>
  7. #include "log4c.h"
  8. #if 0
  9. class CLogContext
  10. {
  11. public:
  12. CLogContext(const char *pFileName, const char *pFuncName, int nLineNo):
  13. m_pFileName(pFileName),
  14. m_pFuncName(pFuncName),
  15. m_nLinNo(nLineNo)
  16. {
  17. m_nLogNum = 0;
  18. }
  19. static SetInfo(const char *pFileName, const char *pFuncName, int nLineNo)
  20. {
  21. CLogContext(pFileName, pFuncName, nLineNo);
  22. }
  23. void Output(const char *pFormat, ...)
  24. {
  25. #if 0
  26. char *file_info;
  27. char *new_format;
  28. size_t info_len;
  29. size_t new_format_len;
  30. va_list va;
  31. info_len = strlen(format) + 50;
  32. file_info = (char *) malloc(info_len);
  33. sprintf(file_info, format, ++LOGNUM, func, line, file);
  34. new_format_len = strlen(file_info) + strlen(a_format) + 2;
  35. new_format = (char *) malloc(new_format_len);
  36. sprintf(new_format, "%s %s", file_info, a_format);
  37. va_start(va, a_format);
  38. log4c_category_vlog(mycat, LOG4C_PRIORITY_ERROR, new_format, va);
  39. va_end(va);
  40. free(file_info);
  41. free(new_format);
  42. #endif
  43. }
  44. log4c_category_t* m_pLogCategory;
  45. static CLogContext* m_pLogContext;
  46. private:
  47. const char *m_pFileName;
  48. const char *m_pFuncName;
  49. int m_nLinNo;
  50. int m_nLogNum;
  51. };
  52. #define LOG(fmt, arg...) CLogContext::SetInfo(__FILE__, __LINE__, __FUNCTION__).Output(fmt, arg...)
  53. #endif
  54. // TODO: 在此处引用程序要求的附加头文件