forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.hpp
More file actions
73 lines (63 loc) · 3.71 KB
/
log.hpp
File metadata and controls
73 lines (63 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef _AV_TRANSCODER_LOG_HPP
#define _AV_TRANSCODER_LOG_HPP
#include <AvTranscoder/common.hpp>
extern "C" {
#include <libavutil/log.h>
}
#include <sstream>
#include <fstream>
namespace avtranscoder
{
#define LOG_FILE "avtranscoder.log"
#define LOG_DEBUG(...) \
{ \
std::stringstream os; \
os << __VA_ARGS__; \
Logger::log(AV_LOG_DEBUG, os.str()); \
}
#define LOG_INFO(...) \
{ \
std::stringstream os; \
os << __VA_ARGS__; \
Logger::log(AV_LOG_INFO, os.str()); \
}
#define LOG_WARN(...) \
{ \
std::stringstream os; \
os << __VA_ARGS__; \
Logger::log(AV_LOG_WARNING, os.str()); \
}
#define LOG_ERROR(...) \
{ \
std::stringstream os; \
os << __VA_ARGS__; \
Logger::log(AV_LOG_ERROR, os.str()); \
}
/// Logger class which contains static functions to use ffmpeg/libav log system
class AvExport Logger
{
public:
/**
* @brief Set the log level of ffmpeg/libav.
* @param level: refer to define AV_LOG_xxx (from AV_LOG_QUIET to AV_LOG_DEBUG)
* @note By default AV_LOG_INFO
* @see SWIG interface avLogLevel.i
*/
static void setLogLevel(const int level);
/**
* @brief Log with the ffmpeg/libav log system
* @note you can use macro LOG_* to log at DEBUG/INFO/WARN/ERROR level
* @param msg: the message will be prefixed by '[avTranscoder - <level>]'
* @param msg: the message will be suffixed by '\n'
*/
static void log(const int level, const std::string& msg);
/**
* @brief Log ffmpeg/libav and avtranscoder informations in a text file.
* @note log filename is avtranscoder.log
*/
static void logInFile();
private:
static std::string logHeaderMessage; ///< First caracters present for each logging message
};
}
#endif