logging disable by default

This commit is contained in:
2026-03-29 01:57:48 +01:00
committed by Romain BOULLARD
parent ea53392645
commit b769357bd0
2 changed files with 27 additions and 12 deletions

View File

@@ -5,15 +5,13 @@
int main(int argc, char** argv)
{
Bin2CPP::Singleton<Bin2CPP::Log>::Lifetime loggerLifetime;
CLI::App app {"Bin2CPP allows you to generate a C++ header containing the binary content of an input file"};
argv = app.ensure_utf8(argv);
std::string input;
app.add_option("-f,--input", input, "The input file")->required();
app.add_option("-f,--input", input, "The input file");
std::string output;
app.add_option("-o,--output", output, "The output file")->required();
app.add_option("-o,--output", output, "The output file");
std::optional<std::string> arrayType;
app.add_option("--arrayType", arrayType, "The type of the array");
std::optional<std::string> arrayInclude;
@@ -22,9 +20,14 @@ int main(int argc, char** argv)
app.add_option("--arrayName", arrayName, "The array name");
std::optional<std::string> customNamespace;
app.add_option("--namespace", customNamespace, "The namespace");
bool verbose = false;
app.add_option("--verbose", verbose, "Activate logging");
CLI11_PARSE(app, argc, argv);
std::unique_ptr<Bin2CPP::Singleton<Bin2CPP::Log>::Lifetime> loggerLifetime =
verbose ? std::make_unique<Bin2CPP::Singleton<Bin2CPP::Log>::Lifetime>() : nullptr;
Bin2CPP::Generator generator(input);
if (arrayType)
{

View File

@@ -79,37 +79,49 @@ class Log
#define BIN2CPP_LOG_INFO(fmt, ...) \
do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} \
} while (0)
#define BIN2CPP_LOG_WARN(fmt, ...) \
do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} \
} while (0)
#define BIN2CPP_LOG_ERROR(fmt, ...) \
do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} \
} while (0)
#define BIN2CPP_LOG_FATAL(fmt, ...) \
do \
{ \
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
{ \
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
{ \
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
} \
} \
} while (0)
#endif