From 22214b8c65fd01ec387634679626448702e6cb06 Mon Sep 17 00:00:00 2001 From: Wonsup Yoon Date: Wed, 17 Nov 2021 10:30:55 +0900 Subject: [PATCH] [Hotfix] Fix solution debugging log --- include/E/Networking/E_NetworkLog.hpp | 17 +++++++++++++++++ src/Networking/E_Host.cpp | 2 +- src/Networking/E_NetworkLog.cpp | 10 +++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/E/Networking/E_NetworkLog.hpp b/include/E/Networking/E_NetworkLog.hpp index 06fdb01b6..69fbcc120 100644 --- a/include/E/Networking/E_NetworkLog.hpp +++ b/include/E/Networking/E_NetworkLog.hpp @@ -92,6 +92,23 @@ class NetworkLog { #endif ; + /** + * @brief Prints log with specified log level and format. + * NetworkLog::print_log prints logs specified in log level parameter. + * For example, if log level is set to TCP_LOG, it only prints TCP_LOG logs. + * If you want to print multiple log levels in NetworkLog, + * you can set log level with OR operation (i.e. SYSCALL_ERROR | + * MODULE_ERROR). + * + * @note Log::print_log + * + * @param level log level + * @param format Format string + * @param args Print arguments for format string + * + */ + void vprint_log(uint64_t level, const char *format, va_list args); + public: /** * @brief Default log level. diff --git a/src/Networking/E_Host.cpp b/src/Networking/E_Host.cpp index 1e9cef049..1a2cec6f4 100644 --- a/src/Networking/E_Host.cpp +++ b/src/Networking/E_Host.cpp @@ -250,7 +250,7 @@ Size HostModule::getWireSpeed(int port_num) { void HostModule::print_log(uint64_t level, const char *format, ...) { va_list arglist; va_start(arglist, format); - host.print_log(level, format, arglist); + host.vprint_log(level, format, arglist); va_end(arglist); } diff --git a/src/Networking/E_NetworkLog.cpp b/src/Networking/E_NetworkLog.cpp index 087cb06cb..1d536262c 100644 --- a/src/Networking/E_NetworkLog.cpp +++ b/src/Networking/E_NetworkLog.cpp @@ -34,13 +34,17 @@ NetworkLog::NetworkLog(System &system, uint64_t level) : system(system) { NetworkLog::~NetworkLog() {} void NetworkLog::print_log(uint64_t level, const char *format, ...) { + va_list args; + va_start(args, format); + vprint_log(level, format, args); + va_end(args); +} + +void NetworkLog::vprint_log(uint64_t level, const char *format, va_list args) { if (!(((1UL << level) & this->level))) return; printf("Time[%" PRIu64 "]\t", system.getCurrentTime()); - va_list args; - va_start(args, format); vprintf(format, args); - va_end(args); printf("\n"); fflush(stdout); }