Agora C++ API Reference for All Platforms
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 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
10 #include <cstdint>
11 #endif
12 
13 #ifndef OPTIONAL_ENUM_CLASS
14 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
15 #define OPTIONAL_ENUM_CLASS enum class
16 #else
17 #define OPTIONAL_ENUM_CLASS enum
18 #endif
19 #endif
20 
21 #ifndef OPTIONAL_LOG_LEVEL_SPECIFIER
22 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
23 #define OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL::
24 #else
25 #define OPTIONAL_LOG_LEVEL_SPECIFIER
26 #endif
27 #endif
28 
29 namespace agora {
30 namespace commons {
31 
35 OPTIONAL_ENUM_CLASS LOG_LEVEL {
36  LOG_LEVEL_NONE = 0x0000,
37  LOG_LEVEL_INFO = 0x0001,
38  LOG_LEVEL_WARN = 0x0002,
39  LOG_LEVEL_ERROR = 0x0004,
40  LOG_LEVEL_FATAL = 0x0008,
41 };
42 
43 /*
44 The SDK uses ILogWriter class Write interface to write logs as application
45 The application inherits the methods Write() to implentation their own log writ
46 
47 Write has default implementation, it writes logs to files.
48 Application can use setLogFile() to change file location, see description of set
49 */
50 class ILogWriter {
51  public:
60  virtual int32_t writeLog(LOG_LEVEL level, const char* message, uint16_t length) = 0;
61 
62  virtual ~ILogWriter() {}
63 };
64 
67  LOG_FILTER_DEBUG = 0x080f,
68  LOG_FILTER_INFO = 0x000f,
69  LOG_FILTER_WARN = 0x000e,
70  LOG_FILTER_ERROR = 0x000c,
72  LOG_FILTER_MASK = 0x80f,
73 };
74 
75 const uint32_t MAX_LOG_SIZE = 20 * 1024 * 1024; // 20MB
76 const uint32_t MIN_LOG_SIZE = 128 * 1024; // 128KB
79 const uint32_t DEFAULT_LOG_SIZE_IN_KB = 1024;
80 
83 struct LogConfig
84 {
87  const char* filePath;
90  uint32_t fileSizeInKB;
94 
95  LogConfig() : filePath(NULL), fileSizeInKB(DEFAULT_LOG_SIZE_IN_KB), level(OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL_INFO) {}
96 };
97 } //namespace commons
98 } //namespace agora
99 
100 #undef OPTIONAL_LOG_LEVEL_SPECIFIER
agora::commons::LOG_FILTER_TYPE
LOG_FILTER_TYPE
Definition: IAgoraLog.h:65
agora::commons::ILogWriter
Definition: IAgoraLog.h:50
agora::commons::LOG_FILTER_MASK
@ LOG_FILTER_MASK
Definition: IAgoraLog.h:72
agora::commons::LogConfig::filePath
const char * filePath
Definition: IAgoraLog.h:87
agora
Definition: AgoraAtomicOps.h:21
agora::commons::LogConfig::fileSizeInKB
uint32_t fileSizeInKB
Definition: IAgoraLog.h:90
agora::commons::DEFAULT_LOG_SIZE_IN_KB
const uint32_t DEFAULT_LOG_SIZE_IN_KB
Definition: IAgoraLog.h:79
agora::commons::LOG_FILTER_ERROR
@ LOG_FILTER_ERROR
Definition: IAgoraLog.h:70
agora::commons::LOG_FILTER_OFF
@ LOG_FILTER_OFF
Definition: IAgoraLog.h:66
agora::commons::MIN_LOG_SIZE
const uint32_t MIN_LOG_SIZE
Definition: IAgoraLog.h:76
agora::commons::LOG_FILTER_DEBUG
@ LOG_FILTER_DEBUG
Definition: IAgoraLog.h:67
agora::commons::LOG_FILTER_INFO
@ LOG_FILTER_INFO
Definition: IAgoraLog.h:68
agora::commons::LOG_LEVEL
OPTIONAL_ENUM_CLASS LOG_LEVEL
Definition: IAgoraLog.h:35
agora::commons::ILogWriter::writeLog
virtual int32_t writeLog(LOG_LEVEL level, const char *message, uint16_t length)=0
agora::commons::LogConfig::LogConfig
LogConfig()
Definition: IAgoraLog.h:95
agora::commons::LOG_FILTER_CRITICAL
@ LOG_FILTER_CRITICAL
Definition: IAgoraLog.h:71
agora::commons::LogConfig
Definition: IAgoraLog.h:84
agora::commons::ILogWriter::~ILogWriter
virtual ~ILogWriter()
Definition: IAgoraLog.h:62
agora::commons::MAX_LOG_SIZE
const uint32_t MAX_LOG_SIZE
Definition: IAgoraLog.h:75
agora::commons::LOG_FILTER_WARN
@ LOG_FILTER_WARN
Definition: IAgoraLog.h:69
agora::commons::LogConfig::level
LOG_LEVEL level
Definition: IAgoraLog.h:93