123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include <android/log.h>
- #include <errno.h>
- #include <string>
- #include <sys/stat.h>
- #include "CLogDefine.h"
- #if 0
- #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__ )
- #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__ )
- #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__ )
- #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
- #define ALOGF(...) __android_log_print(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__)
- #else
- #define ALOGD(...)
- #define ALOGI(...)
- #define ALOGW(...)
- #define ALOGE(...)
- #define ALOGF(...)
- #endif
- class Logger {
- public:
- Logger();
- /**
- * 初始化日志选项
- * \param pFilePath 日志路径
- * \param filename 日志名称
- * \param logLevel 日志级别
- * \param printScreen 打印的级别
- * \return
- */
- int _LogInit(const char* pFilePath, int logLevel, int printScreen);
- /**
- * 写日志
- * \param level
- * \param strFormat
- * \param ...
- */
- void WriteTextLog(int level, const char* strFormat, ...);
- /**
- * 向文件中写入日志
- * \param level
- * \param log
- */
- void WriteTextLogBottom(int level, const char* timeStr, const char* levelInfor, const char* log);
- /**
- * 关闭日志库
- */
- void _LogClose();
- private:
- int g_RollingPtr;
- int g_log_file_level;
- int g_log_screen_level;
- std::string g_logFilePath;
- char* g_log_info;
- FILE* _fp;
- };
|