Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions src/include/utils/debug_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
#include <iomanip>
#include <string>

namespace debug_utils {
inline bool& quiet_mode() {
static bool enabled = false;
return enabled;
}

inline void set_quiet_mode(bool enabled) {
quiet_mode() = enabled;
}

inline bool is_quiet_mode() {
return quiet_mode();
}
} // namespace debug_utils

#ifndef VERBOSE
#define VERBOSE 0
#endif
Expand Down Expand Up @@ -109,19 +124,23 @@
/// \param msg the message to log
#define header_print(header, msg) \
do { \
std::ostringstream oss; \
oss << msg; \
std::cout << '[' << header << "] " << oss.str() << std::endl; \
if (!debug_utils::is_quiet_mode()) { \
std::ostringstream oss; \
oss << msg; \
std::cout << '[' << header << "] " << oss.str() << std::endl; \
} \
} while (0)

/// \brief header_print_r macro, in red color
/// \param header the header of the message
/// \param msg the message to log
#define header_print_r(header, msg) \
do { \
std::ostringstream oss; \
oss << msg; \
std::cerr << "\033[31m[" << header << "] " << oss.str() << "\033[0m" << std::endl; \
if (!debug_utils::is_quiet_mode()) { \
std::ostringstream oss; \
oss << msg; \
std::cerr << "\033[31m[" << header << "] " << oss.str() << "\033[0m" << std::endl; \
} \
} while (0)


Expand All @@ -130,9 +149,11 @@
/// \param msg the message to log
#define header_print_g(header, msg) \
do { \
std::ostringstream oss; \
oss << msg; \
std::cout << "\033[32m[" << header << "] " << oss.str() << "\033[0m" << std::endl; \
if (!debug_utils::is_quiet_mode()) { \
std::ostringstream oss; \
oss << msg; \
std::cout << "\033[32m[" << header << "] " << oss.str() << "\033[0m" << std::endl; \
} \
} while (0)

/// \brief box_print macro
Expand Down
19 changes: 12 additions & 7 deletions src/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
#include "server.hpp"
#include "model_list.hpp"
#include "model_downloader.hpp"
#include "update.hpp"
#include "utils/utils.hpp"
#include "program_args.hpp"
#include "update.hpp"
#include "utils/utils.hpp"
#include "utils/debug_utils.hpp"
#include "program_args.hpp"
#include "minja/chat-template.hpp"
#include <cstring>
#include <iostream>
Expand Down Expand Up @@ -469,10 +470,14 @@ int main(int argc, char* argv[]) {

// Parse command line arguments using Boost Program Options
program_args_t parsed_args;
if (!arg_utils::parse_options(argc, argv, parsed_args)) {
return 1; // Help was already printed by Boost Program Options
}

if (!arg_utils::parse_options(argc, argv, parsed_args)) {
return 1; // Help was already printed by Boost Program Options
}

if (parsed_args.command == "serve" && parsed_args.sub_process_mode) {
debug_utils::set_quiet_mode(true);
}


// Get the command, model tag, and force flag
std::string exe_dir = utils::get_executable_directory();
Expand Down
Loading