logging disable by default
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -80,36 +80,48 @@ class Log
|
||||
#define BIN2CPP_LOG_INFO(fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
|
||||
{ \
|
||||
QUILL_LOG_INFO(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
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 (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
|
||||
{ \
|
||||
QUILL_LOG_WARNING(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
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 (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
|
||||
{ \
|
||||
QUILL_LOG_ERROR(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
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 (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
if (Bin2CPP::Singleton<Bin2CPP::Log>::HasInstance()) \
|
||||
{ \
|
||||
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
if (quill::Logger* logger = Bin2CPP::Singleton<Bin2CPP::Log>::Instance().GetLogger()) \
|
||||
{ \
|
||||
QUILL_LOG_CRITICAL(logger, fmt __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user