Agora Java API Reference for Android
IAgoraLog.h
1 //
2 // Agora Media SDK
3 //
4 // Copyright (c) 2015 Agora IO. All rights reserved.
5 //
6 #pragma once
7 
8 #include <cstdlib>
9 #include <stdint.h>
10 
11 #ifndef OPTIONAL_ENUM_CLASS
12 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
13 #define OPTIONAL_ENUM_CLASS enum class
14 #else
15 #define OPTIONAL_ENUM_CLASS enum
16 #endif
17 #endif
18 
19 #ifndef OPTIONAL_LOG_LEVEL_SPECIFIER
20 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
21 #define OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL::
22 #else
23 #define OPTIONAL_LOG_LEVEL_SPECIFIER
24 #endif
25 #endif
26 
27 namespace agora {
28 namespace commons {
29 
33 OPTIONAL_ENUM_CLASS LOG_LEVEL {
34  LOG_LEVEL_NONE = 0x0000,
35  LOG_LEVEL_INFO = 0x0001,
36  LOG_LEVEL_WARN = 0x0002,
37  LOG_LEVEL_ERROR = 0x0004,
38  LOG_LEVEL_FATAL = 0x0008,
39  LOG_LEVEL_API_CALL = 0x0010,
40 };
41 
42 /*
43 The SDK uses ILogWriter class Write interface to write logs as application
44 The application inherits the methods Write() to implentation their own log writ
45 
46 Write has default implementation, it writes logs to files.
47 Application can use setLogFile() to change file location, see description of set
48 */
49 class ILogWriter {
50  public:
59  virtual int32_t writeLog(LOG_LEVEL level, const char* message, uint16_t length) = 0;
60 
61  virtual ~ILogWriter() {}
62 };
63 
64 enum LOG_FILTER_TYPE {
65  LOG_FILTER_OFF = 0,
66  LOG_FILTER_DEBUG = 0x080f,
67  LOG_FILTER_INFO = 0x000f,
68  LOG_FILTER_WARN = 0x000e,
69  LOG_FILTER_ERROR = 0x000c,
70  LOG_FILTER_CRITICAL = 0x0008,
71  LOG_FILTER_MASK = 0x80f,
72 };
73 
74 const uint32_t MAX_LOG_SIZE = 20 * 1024 * 1024; // 20MB
75 const uint32_t MIN_LOG_SIZE = 128 * 1024; // 128KB
78 const uint32_t DEFAULT_LOG_SIZE_IN_KB = 1024;
79 
82 struct LogConfig {
85  const char* filePath;
88  uint32_t fileSizeInKB;
91  LOG_LEVEL level;
92 
93  LogConfig() : filePath(NULL), fileSizeInKB(DEFAULT_LOG_SIZE_IN_KB), level(OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL_INFO) {}
94 };
95 } // namespace commons
96 } // namespace agora
97 
98 #undef OPTIONAL_LOG_LEVEL_SPECIFIER
agora::commons::ILogWriter
Definition: IAgoraLog.h:49
agora::commons::LogConfig::filePath
const char * filePath
Definition: IAgoraLog.h:85
agora::commons::LogConfig::fileSizeInKB
uint32_t fileSizeInKB
Definition: IAgoraLog.h:88
agora::commons::ILogWriter::writeLog
virtual int32_t writeLog(LOG_LEVEL level, const char *message, uint16_t length)=0
agora::commons::LogConfig
Definition: IAgoraLog.h:82
agora::commons::LogConfig::level
LOG_LEVEL level
Definition: IAgoraLog.h:91