MCPcopy Create free account
hub / github.com/CasparCG/server / log_callback

Function log_callback

src/modules/ffmpeg/ffmpeg.cpp:58–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void log_callback(void* ptr, int level, const char* fmt, va_list vl)
59{
60 static thread_local bool print_prefix_tss = true;
61
62 char line[1024];
63 AVClass* avc = ptr != nullptr ? *static_cast<AVClass**>(ptr) : nullptr;
64 if (level > AV_LOG_DEBUG)
65 return;
66 line[0] = 0;
67
68#undef fprintf
69 if (print_prefix_tss && (avc != nullptr)) {
70 if (avc->parent_log_context_offset != 0) {
71 AVClass** parent =
72 *reinterpret_cast<AVClass***>(static_cast<uint8_t*>(ptr) + avc->parent_log_context_offset);
73 if ((parent != nullptr) && (*parent != nullptr))
74 std::snprintf(line, sizeof(line), "[%s @ %p] ", (*parent)->item_name(parent), parent);
75 }
76 std::snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);
77 }
78
79 std::vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);
80
81 print_prefix_tss = (strlen(line) != 0u) && line[strlen(line) - 1] == '\n';
82
83 sanitize(reinterpret_cast<uint8_t*>(line));
84
85 if (strstr(line, "Assuming an incorrectly") != nullptr) {
86 return;
87 }
88
89 try {
90 if (level == AV_LOG_VERBOSE)
91 CASPAR_LOG(trace) << L"[ffmpeg] " << line;
92 else if (level == AV_LOG_DEBUG)
93 CASPAR_LOG(trace) << L"[ffmpeg] " << line;
94 else if (level == AV_LOG_INFO)
95 CASPAR_LOG(info) << L"[ffmpeg] " << line;
96 else if (level == AV_LOG_WARNING)
97 CASPAR_LOG(warning) << L"[ffmpeg] " << line;
98 else if (level == AV_LOG_ERROR)
99 CASPAR_LOG(error) << L"[ffmpeg] " << line;
100 else if (level == AV_LOG_FATAL)
101 CASPAR_LOG(fatal) << L"[ffmpeg] " << line;
102 else
103 CASPAR_LOG(trace) << L"[ffmpeg] " << line;
104 } catch (...) {
105 }
106}
107
108void log_for_thread(void* ptr, int level, const char* fmt, va_list vl) { log_callback(ptr, level, fmt, vl); }
109

Callers 1

log_for_threadFunction · 0.85

Calls 1

sanitizeFunction · 0.85

Tested by

no test coverage detected