summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2024-04-12 15:39:06 +0200
committerGitHub <noreply@github.com>2024-04-12 15:39:06 +0200
commit66a9c6bab3c76cc7f0c60234401ff4e050b7afa1 (patch)
tree3d5a3e5469fe32d7220bba528208ef804c3b4569
parent762365d20a2a7282c906ee170c644a3a96be3a21 (diff)
parente391109df237e94c616d276401e13602d19f29f1 (diff)
downloadfork-godot-webrtc-native-66a9c6bab3c76cc7f0c60234401ff4e050b7afa1.tar.gz
fork-godot-webrtc-native-66a9c6bab3c76cc7f0c60234401ff4e050b7afa1.tar.bz2
fork-godot-webrtc-native-66a9c6bab3c76cc7f0c60234401ff4e050b7afa1.zip
Merge pull request #141 from Ughuuu/logging-in-godot
Use Godot primitives for logging, change default log level
-rw-r--r--src/WebRTCLibPeerConnection.cpp22
1 files changed, 21 insertions, 1 deletions
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 <godot_cpp/variant/utility_functions.hpp>
+#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
}