From e391109df237e94c616d276401e13602d19f29f1 Mon Sep 17 00:00:00 2001 From: Dragos Daian Date: Thu, 21 Mar 2024 12:59:04 +0100 Subject: Use Godot primitives for logging, change default log level --- src/WebRTCLibPeerConnection.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/WebRTCLibPeerConnection.cpp') diff --git a/src/WebRTCLibPeerConnection.cpp b/src/WebRTCLibPeerConnection.cpp index 69bb89f..bc730a7 100644 --- a/src/WebRTCLibPeerConnection.cpp +++ b/src/WebRTCLibPeerConnection.cpp @@ -39,11 +39,31 @@ using namespace godot_webrtc; #define FAILED Error::FAILED #define ERR_UNCONFIGURED Error::ERR_UNCONFIGURED #define ERR_INVALID_PARAMETER Error::ERR_INVALID_PARAMETER +#define VERBOSE_PRINT(str) Godot::print(str) +#else +#include +#define VERBOSE_PRINT(str) UtilityFunctions::print_verbose(str) #endif +void LogCallback(rtc::LogLevel level, std::string message) { + switch (level) { + case rtc::LogLevel::Fatal: + case rtc::LogLevel::Error: + ERR_PRINT(message.c_str()); + return; + case rtc::LogLevel::Warning: + WARN_PRINT(message.c_str()); + return; + default: + VERBOSE_PRINT(message.c_str()); + return; + } +} void WebRTCLibPeerConnection::initialize_signaling() { #ifdef DEBUG_ENABLED - rtc::InitLogger(rtc::LogLevel::Debug); + rtc::InitLogger(rtc::LogLevel::Debug, LogCallback); +#else + rtc::InitLogger(rtc::LogLevel::Warning, LogCallback); #endif } -- cgit v1.2.3