Colourful logs

This commit is contained in:
DcruBro
2025-11-25 00:36:29 +01:00
parent de3ec98363
commit f776f1fdd1
4 changed files with 19 additions and 22 deletions

View File

@@ -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() {

View File

@@ -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));