Colourful logs
This commit is contained in:
@@ -16,6 +16,10 @@ project(ColumnLynx
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
#set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
#add_compile_options(${CMAKE_CXX_FLAGS_DEBUG})
|
||||
|
||||
add_compile_definitions(DEBUG=1) # TODO: Forcing for now, add dymanic based on compile flags later
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
@@ -67,9 +71,6 @@ else()
|
||||
message(FATAL_ERROR "OpenSSL not found")
|
||||
endif()
|
||||
|
||||
# json
|
||||
#ind_package(nlohmann_json CONFIG REQUIRED)
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Output directories
|
||||
# ---------------------------------------------------------
|
||||
@@ -89,7 +90,7 @@ endforeach()
|
||||
# ---------------------------------------------------------
|
||||
file(GLOB_RECURSE COMMON_SRC CONFIGURE_DEPENDS src/common/*.cpp)
|
||||
add_library(common STATIC ${COMMON_SRC})
|
||||
target_link_libraries(common PUBLIC sodium OpenSSL::SSL OpenSSL::Crypto nlohmann_json::nlohmann_json)
|
||||
target_link_libraries(common PUBLIC sodium OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_include_directories(common PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${sodium_SOURCE_DIR}/src/libsodium/include
|
||||
@@ -102,7 +103,7 @@ target_compile_definitions(common PUBLIC ASIO_STANDALONE)
|
||||
# ---------------------------------------------------------
|
||||
file(GLOB_RECURSE CLIENT_SRC CONFIGURE_DEPENDS src/client/*.cpp)
|
||||
add_executable(client ${CLIENT_SRC})
|
||||
target_link_libraries(client PRIVATE common sodium OpenSSL::SSL OpenSSL::Crypto nlohmann_json::nlohmann_json)
|
||||
target_link_libraries(client PRIVATE common sodium OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_include_directories(client PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${sodium_SOURCE_DIR}/src/libsodium/include
|
||||
@@ -116,7 +117,7 @@ set_target_properties(client PROPERTIES OUTPUT_NAME "columnlynx_client")
|
||||
# ---------------------------------------------------------
|
||||
file(GLOB_RECURSE SERVER_SRC CONFIGURE_DEPENDS src/server/*.cpp)
|
||||
add_executable(server ${SERVER_SRC})
|
||||
target_link_libraries(server PRIVATE common sodium OpenSSL::SSL OpenSSL::Crypto nlohmann_json::nlohmann_json)
|
||||
target_link_libraries(server PRIVATE common sodium OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_include_directories(server PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${sodium_SOURCE_DIR}/src/libsodium/include
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace ColumnLynx::Utils {
|
||||
void log(const std::string &msg);
|
||||
void warn(const std::string &msg);
|
||||
void error(const std::string &msg);
|
||||
void debug(const std::string &msg);
|
||||
|
||||
std::string getHostname();
|
||||
std::string getVersion();
|
||||
|
||||
@@ -6,15 +6,23 @@
|
||||
|
||||
namespace ColumnLynx::Utils {
|
||||
void log(const std::string &msg) {
|
||||
std::cout << "[LOG] " << msg << std::endl;
|
||||
std::cout << "\033[0m[LOG] " << msg << std::endl;
|
||||
}
|
||||
|
||||
void warn(const std::string &msg) {
|
||||
std::cerr << "[WARN] " << msg << std::endl;
|
||||
std::cerr << "\033[33m[WARN] " << msg << "\033[0m" << std::endl;
|
||||
}
|
||||
|
||||
void error(const std::string &msg) {
|
||||
std::cerr << "[ERROR] " << msg << std::endl;
|
||||
std::cerr << "\033[31m[ERROR] " << msg << "\033[0m" << std::endl;
|
||||
}
|
||||
|
||||
void debug(const std::string &msg) {
|
||||
#if DEBUG || _DEBUG
|
||||
std::cerr << "\033[95m[DEBUG] " << msg << "\033[0m" << std::endl;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string getHostname() {
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <unordered_set>
|
||||
#include <cxxopts/cxxopts.hpp>
|
||||
#include <columnlynx/common/net/virtual_interface.hpp>
|
||||
//#include <nlohmann/json.hpp>
|
||||
|
||||
using asio::ip::tcp;
|
||||
using namespace ColumnLynx::Utils;
|
||||
@@ -67,18 +66,6 @@ int main(int argc, char** argv) {
|
||||
std::shared_ptr<VirtualInterface> tun = std::make_shared<VirtualInterface>("utun0");
|
||||
log("Using virtual interface: " + tun->getName());
|
||||
|
||||
/*
|
||||
// Load the config
|
||||
std::ifstream f(configPath);
|
||||
if (!f) {
|
||||
error("Could not open config.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
nlohmann::json j;
|
||||
f >> j; // parse
|
||||
*/
|
||||
|
||||
// Generate a temporary keypair, replace with actual CA signed keys later (Note, these are stored in memory)
|
||||
LibSodiumWrapper sodiumWrapper = LibSodiumWrapper();
|
||||
log("Server public key: " + bytesToHexString(sodiumWrapper.getPublicKey(), crypto_sign_PUBLICKEYBYTES));
|
||||
|
||||
Reference in New Issue
Block a user