Debian Codegraph @

sys/qsv/libmfx/dispatcher/vpl/mfx_dispatcher_vpl_log.h

raw symbols SCIP
1 /*############################################################################
2 # Copyright (C) Intel Corporation
3 #
4 # SPDX-License-Identifier: MIT
5 ############################################################################*/
6
7 #ifndef DISPATCHER_VPL_MFX_DISPATCHER_VPL_LOG_H_
8 #define DISPATCHER_VPL_MFX_DISPATCHER_VPL_LOG_H_
9
10 /* oneVPL Dispatcher Debug Log
11 * The debug output of the dispatcher is controlled with the ONEVPL_DISPATCHER_LOG environment variable.
12 * To enable log output, set the ONEVPL_DISPATCHER_LOG environment variable value equals to "ON".
13 *
14 * By default, oneVPL dispatcher prints all log messages to the console.
15 * To redirect log output to the desired file, set the ONEVPL_DISPATCHER_LOG_FILE environmental
16 * variable with the file name of the log file.
17 */
18
19 #include <stdarg.h>
20 #include <stdio.h>
21
22 #include <string>
23
24 #include "vpl/mfxdispatcher.h"
25 #include "vpl/mfxvideo.h"
26
27 #ifndef __FUNC_NAME__
28 #if defined(_WIN32) || defined(_WIN64)
29 #define __FUNC_NAME__ __FUNCTION__
30 #else
31 #define __FUNC_NAME__ __PRETTY_FUNCTION__
32 #endif
33 #endif
34
35 class DispatcherLogVPL {
36 public:
37 DispatcherLogVPL();
38 ~DispatcherLogVPL();
39
40 mfxStatus Init(mfxU32 logLevel, const std::string &logFileName);
41 mfxStatus LogMessage(const char *msdk, ...);
42
43 mfxU32 m_logLevel;
44
45 private:
46 std::string m_logFileName;
47 FILE *m_logFile;
48 };
49
50 class DispatcherLogVPLFunction {
51 public:
52 DispatcherLogVPLFunction(DispatcherLogVPL *dispLog, const char *fnName)
53 : m_dispLog(),
54 m_fnName() {
55 m_dispLog = dispLog;
56
57 if (m_dispLog && m_dispLog->m_logLevel) {
58 m_fnName = fnName;
59 m_dispLog->LogMessage("function: %s (enter)", m_fnName.c_str());
60 }
61 }
62
63 ~DispatcherLogVPLFunction() {
64 if (m_dispLog && m_dispLog->m_logLevel)
65 m_dispLog->LogMessage("function: %s (return)", m_fnName.c_str());
66 }
67
68 private:
69 DispatcherLogVPL *m_dispLog;
70 std::string m_fnName;
71 };
72
73 #define DISP_LOG_FUNCTION(dispLog) DispatcherLogVPLFunction _dispLogFn(dispLog, __FUNC_NAME__);
74 #define DISP_LOG_MESSAGE(dispLog, ...) \
75 { \
76 if (dispLog) { \
77 (dispLog)->LogMessage(__VA_ARGS__); \
78 } \
79 }
80
81 #endif // DISPATCHER_VPL_MFX_DISPATCHER_VPL_LOG_H_