logging disable by default
All checks were successful
Bin2CPP / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 1m29s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 1m30s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd (Unity Build: OFF) (push) Successful in 43s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd (Unity Build: ON) (push) Successful in 45s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Successful in 53s
Bin2CPP / Build & Test Debug with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Successful in 54s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 1m18s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 1m17s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd (Unity Build: OFF) (push) Successful in 53s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd (Unity Build: ON) (push) Successful in 56s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Successful in 1m12s
Bin2CPP / Build & Test RelWithDebInfo with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Successful in 1m20s
Bin2CPP / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Successful in 1m5s
Bin2CPP / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Successful in 1m0s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd (Unity Build: OFF) (push) Successful in 48s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd (Unity Build: ON) (push) Successful in 49s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd_asan (Unity Build: OFF) (push) Successful in 1m5s
Bin2CPP / Clang Format Checks (push) Successful in 9s
Bin2CPP / Build & Test Release with ./ConanProfiles/clangd_asan (Unity Build: ON) (push) Successful in 1m10s
Conan Packaging / Package Bin2CPP/1.0.0 (push) Successful in 1m5s

This commit is contained in:
2026-03-29 01:57:48 +01:00
parent 6886599bdb
commit 6bfd732541
2 changed files with 27 additions and 12 deletions

View File

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

View File

@@ -80,36 +80,48 @@ class Log
#define BIN2CPP_LOG_INFO(fmt, ...) \ #define BIN2CPP_LOG_INFO(fmt, ...) \
do \ 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) } while (0)
#define BIN2CPP_LOG_WARN(fmt, ...) \ #define BIN2CPP_LOG_WARN(fmt, ...) \
do \ 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) } while (0)
#define BIN2CPP_LOG_ERROR(fmt, ...) \ #define BIN2CPP_LOG_ERROR(fmt, ...) \
do \ 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) } while (0)
#define BIN2CPP_LOG_FATAL(fmt, ...) \ #define BIN2CPP_LOG_FATAL(fmt, ...) \
do \ 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) } while (0)
#endif #endif