Skip to content

Commit

Permalink
[Hotfix] Fix solution debugging log
Browse files Browse the repository at this point in the history
  • Loading branch information
Pusnow committed Nov 17, 2021
1 parent c74958d commit 22214b8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
17 changes: 17 additions & 0 deletions include/E/Networking/E_NetworkLog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Networking/E_Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 7 additions & 3 deletions src/Networking/E_NetworkLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 22214b8

Please sign in to comment.