GLOG comat macro LOG_F
This commit is contained in:
parent
e9ca6a04e7
commit
8119729fb0
|
@ -6,8 +6,9 @@ version = "0.1.0"
|
|||
|
||||
[lib]
|
||||
name = "libjournal"
|
||||
cc-flags = ["-DJOURNAL_GLOG_COMPAT"]
|
||||
|
||||
[[bin]]
|
||||
name = "journal"
|
||||
cc-flags = ["-DJOURNAL_ALL", "-gcodeview", "-g"]
|
||||
cc-flags = ["-DJOURNAL_GLOG_COMPAT", "-DJOURNAL_ALL", "-gcodeview", "-g"]
|
||||
ld-flags = ["-g", "-gcodeview"]
|
|
@ -76,7 +76,11 @@ auto add_sink(std::shared_ptr<std::ostream> stream,
|
|||
const LogVerbosity &min = LogVerbosity::Trace,
|
||||
const LogVerbosity &max = LogVerbosity::Error) -> void;
|
||||
|
||||
#ifdef JOURNAL_ALL
|
||||
/// JOURNAL_NONE: undefines all logs
|
||||
/// JOURNAL_ALL: defines all logs, on by default
|
||||
/// JOURNAL_NOT_ALL: does not define any logs by default even it JOURNAL_ALL is
|
||||
/// defined, off by default
|
||||
#if defined(JOURNAL_ALL) && !defined(JOURNAL_NONE) && !defined(JOURNAL_NOT_ALL)
|
||||
#define JOURNAL_TRACE
|
||||
#define JOURNAL_DEBUG
|
||||
#define JOURNAL_INFO
|
||||
|
@ -84,6 +88,14 @@ auto add_sink(std::shared_ptr<std::ostream> stream,
|
|||
#define JOURNAL_ERROR
|
||||
#endif
|
||||
|
||||
#if defined(JOURNAL_NONE)
|
||||
#undef JOURNAL_TRACE
|
||||
#undef JOURNAL_DEBUG
|
||||
#undef JOURNAL_INFO
|
||||
#undef JOURNAL_WARN
|
||||
#undef JOURNAL_ERROR
|
||||
#endif
|
||||
|
||||
#ifdef JOURNAL_TRACE
|
||||
template <typename... Args>
|
||||
inline constexpr auto
|
||||
|
@ -149,4 +161,15 @@ template <typename... Args>
|
|||
inline constexpr auto error(std::string_view fmt, Args... args) -> void {}
|
||||
#endif
|
||||
|
||||
/// JOURNAL_GLOG_COMPAT: enables LOG_F macro format which GLOG and Loguru use
|
||||
/// for compatibility, on by default
|
||||
#if defined(JOURNAL_GLOG_COMPAT)
|
||||
#define LOG_F_TRACE(...) trace(__VA_ARGS__)
|
||||
#define LOG_F_DEBUG(...) debug(__VA_ARGS__)
|
||||
#define LOG_F_INFO(...) info(__VA_ARGS__)
|
||||
#define LOG_F_WARN(...) warn(__VA_ARGS__)
|
||||
#define LOG_F_ERROR(...) error(__VA_ARGS__)
|
||||
#define LOG_F(V, ...) LOG_F_##V(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
} // namespace journal
|
Loading…
Reference in a new issue