Integrate plog

This commit is contained in:
Murat Dogan
2019-12-18 10:33:35 +03:00
parent 9749f8d63e
commit 92f08948d3
7 changed files with 24 additions and 2 deletions

3
.gitmodules vendored
View File

@ -1,3 +1,6 @@
[submodule "usrsctp"]
path = deps/usrsctp
url = https://github.com/sctplab/usrsctp.git
[submodule "deps/plog"]
path = deps/plog
url = https://github.com/SergiusTheBest/plog

View File

@ -62,6 +62,7 @@ set_target_properties(datachannel PROPERTIES
target_include_directories(datachannel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/plog/include)
target_link_libraries(datachannel usrsctp-static LibNice::LibNice)
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL ${LIBDATACHANNEL_SOURCES})
@ -72,6 +73,7 @@ set_target_properties(datachannel-static PROPERTIES
target_include_directories(datachannel-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/plog/include)
target_link_libraries(datachannel-static usrsctp-static LibNice::LibNice)
if (USE_GNUTLS)
@ -104,5 +106,6 @@ set_target_properties(tests PROPERTIES
VERSION ${PROJECT_VERSION}
CXX_STANDARD 17)
target_include_directories(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps/plog/include)
target_link_libraries(tests datachannel)

1
deps/plog vendored Submodule

Submodule deps/plog added at 2931644689

View File

@ -47,6 +47,10 @@ struct IceServer {
};
struct Configuration {
enum class LogLevel { none, fatal, error, warning, info, debug, verbose };
Configuration(const LogLevel logLevel_ = LogLevel::error);
std::vector<IceServer> iceServers;
bool enableIceTcp = false;
uint16_t portRangeBegin = 1024;

View File

@ -26,6 +26,7 @@
#include <optional>
#include <string>
#include <vector>
#include <plog/Log.h>
namespace rtc {

View File

@ -17,6 +17,7 @@
*/
#include "configuration.hpp"
#include <plog/Appenders/ColorConsoleAppender.h>
namespace rtc {
@ -43,4 +44,10 @@ IceServer::IceServer(const string &hostname_, const string &service_, string use
: hostname(hostname_), service(service_), type(Type::Turn), username(username_),
password(password_), relayType(relayType_) {}
Configuration::Configuration(const LogLevel logLevel_) {
static plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender;
plog::init(static_cast<plog::Severity>(logLevel_), &consoleAppender);
LOGD << "Logger Initialized";
}
} // namespace rtc

View File

@ -29,7 +29,10 @@ using namespace std;
template <class T> weak_ptr<T> make_weak_ptr(shared_ptr<T> ptr) { return ptr; }
int main(int argc, char **argv) {
// For debug messages
// rtc::Configuration config(Configuration::LogLevel::debug)
rtc::Configuration config;
// config.iceServers.emplace_back("stun.l.google.com:19302");
// config.enableIceTcp = true;