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 {
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 LOG_LEVEL_DEBUG = 0x0020,
41};
42
43/*
44The SDK uses ILogWriter class Write interface to write logs as application
45The application inherits the methods Write() to implentation their own log writ
46
47Write has default implementation, it writes logs to files.
48Application can use setLogFile() to change file location, see description of set
49*/
51 public:
60 virtual int32_t writeLog(LOG_LEVEL level, const char* message, uint16_t length) = 0;
61
62 virtual ~ILogWriter() {}
63};
64
74
75const uint32_t MAX_LOG_SIZE = 20 * 1024 * 1024; // 20MB
76const uint32_t MIN_LOG_SIZE = 128 * 1024; // 128KB
79const uint32_t DEFAULT_LOG_SIZE_IN_KB = 2048;
80
83struct LogConfig {
86 const char* filePath;
89 uint32_t fileSizeInKB;
93
94 LogConfig() : filePath(NULL), fileSizeInKB(DEFAULT_LOG_SIZE_IN_KB), level(OPTIONAL_LOG_LEVEL_SPECIFIER LOG_LEVEL_INFO) {}
95};
96} // namespace commons
97} // namespace agora
98
99#undef OPTIONAL_LOG_LEVEL_SPECIFIER
Definition IAgoraLog.h:50
virtual int32_t writeLog(LOG_LEVEL level, const char *message, uint16_t length)=0
virtual ~ILogWriter()
Definition IAgoraLog.h:62
Definition agora_log_i.h:14
const uint32_t MAX_LOG_SIZE
Definition IAgoraLog.h:75
OPTIONAL_ENUM_CLASS LOG_LEVEL
Definition IAgoraLog.h:33
const uint32_t MIN_LOG_SIZE
Definition IAgoraLog.h:76
const uint32_t DEFAULT_LOG_SIZE_IN_KB
Definition IAgoraLog.h:79
LOG_FILTER_TYPE
Definition IAgoraLog.h:65
@ LOG_FILTER_CRITICAL
Definition IAgoraLog.h:71
@ LOG_FILTER_DEBUG
Definition IAgoraLog.h:67
@ LOG_FILTER_MASK
Definition IAgoraLog.h:72
@ LOG_FILTER_WARN
Definition IAgoraLog.h:69
@ LOG_FILTER_INFO
Definition IAgoraLog.h:68
@ LOG_FILTER_ERROR
Definition IAgoraLog.h:70
@ LOG_FILTER_OFF
Definition IAgoraLog.h:66
Definition AgoraAtomicOps.h:21
LogConfig()
Definition IAgoraLog.h:94
LOG_LEVEL level
Definition IAgoraLog.h:92
uint32_t fileSizeInKB
Definition IAgoraLog.h:89
const char * filePath
Definition IAgoraLog.h:86