Agora C++ API Reference for All Platforms

Loading...
Searching...
No Matches
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
27namespace agora {
28namespace commons {
29
33OPTIONAL_ENUM_CLASS LOG_LEVEL {
37 LOG_LEVEL_NONE = 0x0000,
42 LOG_LEVEL_INFO = 0x0001,
46 LOG_LEVEL_WARN = 0x0002,
50 LOG_LEVEL_ERROR = 0x0004,
54 LOG_LEVEL_FATAL = 0x0008,
55 LOG_LEVEL_API_CALL = 0x0010,
56 LOG_LEVEL_DEBUG = 0x0020,
57};
58
59/*
60The SDK uses ILogWriter class Write interface to write logs as application
61The application inherits the methods Write() to implentation their own log writ
62
63Write has default implementation, it writes logs to files.
64Application can use setLogFile() to change file location, see description of set
65*/
66 class ILogWriter {
67 public:
76 virtual int32_t writeLog(LOG_LEVEL level, const char* message, uint16_t length) = 0;
77
78 virtual ~ILogWriter() {}
79};
80
84 enum LOG_FILTER_TYPE {
88 LOG_FILTER_OFF = 0,
93 LOG_FILTER_DEBUG = 0x080f,
98 LOG_FILTER_INFO = 0x000f,
103 LOG_FILTER_WARN = 0x000e,
107 LOG_FILTER_ERROR = 0x000c,
111 LOG_FILTER_CRITICAL = 0x0008,
112 LOG_FILTER_MASK = 0x80f,
113};
114
115 const uint32_t MAX_LOG_SIZE = 20 * 1024 * 1024; // 20MB
116 const uint32_t MIN_LOG_SIZE = 128 * 1024; // 128KB
119 const uint32_t DEFAULT_LOG_SIZE_IN_KB = 2048;
120
124 struct LogConfig {
137 const char* filePath;
144 uint32_t fileSizeInKB;
150 LOG_LEVEL level;
151
152 LogConfig() : filePath(NULL), fileSizeInKB(DEFAULT_LOG_SIZE_IN_KB), level(OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL_INFO) {}
153};
154} // namespace commons
155} // namespace agora
156
157#undef OPTIONAL_LOG_LEVEL_SPECIFIER
agora::commons::ILogWriter
Definition IAgoraLog.h:66
agora::commons::ILogWriter::writeLog
virtual int32_t writeLog(LOG_LEVEL level, const char *message, uint16_t length)=0
agora::commons::ILogWriter::~ILogWriter
virtual ~ILogWriter()
Definition IAgoraLog.h:78
agora::commons
Definition agora_log_i.h:14
agora::commons::MAX_LOG_SIZE
const uint32_t MAX_LOG_SIZE
Definition IAgoraLog.h:115
agora::commons::LOG_LEVEL
OPTIONAL_ENUM_CLASS LOG_LEVEL
The output log level of the SDK.
Definition IAgoraLog.h:33
agora::commons::MIN_LOG_SIZE
const uint32_t MIN_LOG_SIZE
Definition IAgoraLog.h:116
agora::commons::DEFAULT_LOG_SIZE_IN_KB
const uint32_t DEFAULT_LOG_SIZE_IN_KB
Definition IAgoraLog.h:119
agora::commons::LOG_FILTER_TYPE
LOG_FILTER_TYPE
The output log level of the SDK.
Definition IAgoraLog.h:84
agora::commons::LOG_FILTER_CRITICAL
@ LOG_FILTER_CRITICAL
Definition IAgoraLog.h:111
agora::commons::LOG_FILTER_DEBUG
@ LOG_FILTER_DEBUG
Definition IAgoraLog.h:93
agora::commons::LOG_FILTER_MASK
@ LOG_FILTER_MASK
Definition IAgoraLog.h:112
agora::commons::LOG_FILTER_WARN
@ LOG_FILTER_WARN
Definition IAgoraLog.h:103
agora::commons::LOG_FILTER_INFO
@ LOG_FILTER_INFO
Definition IAgoraLog.h:98
agora::commons::LOG_FILTER_ERROR
@ LOG_FILTER_ERROR
Definition IAgoraLog.h:107
agora::commons::LOG_FILTER_OFF
@ LOG_FILTER_OFF
Definition IAgoraLog.h:88
agora
Definition AgoraAtomicOps.h:21
agora::commons::LogConfig::LogConfig
LogConfig()
Definition IAgoraLog.h:152
agora::commons::LogConfig::level
LOG_LEVEL level
Definition IAgoraLog.h:150
agora::commons::LogConfig::fileSizeInKB
uint32_t fileSizeInKB
Definition IAgoraLog.h:144
agora::commons::LogConfig::filePath
const char * filePath
Definition IAgoraLog.h:137