summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorHendiadyoin1 <leon2002.la@gmail.com>2021-04-15 22:06:18 +0200
committerLinus Groh <mail@linusgroh.de>2021-04-16 20:03:35 +0200
commit2e11b2d35a0ebd38bbde8a0875e93d3830da4ccf (patch)
tree111116911add662816b24ecbd71c324e683e3ae6 /AK
parent2976311536751fd80163bcea24dc5c2d0f127c02 (diff)
downloadserenity-2e11b2d35a0ebd38bbde8a0875e93d3830da4ccf.zip
AK: Add outln_if and warnln_if
This uses the same gating mechanism as dbgln_if and should be equivalent to #define flag etc
Diffstat (limited to 'AK')
-rw-r--r--AK/Format.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/AK/Format.h b/AK/Format.h
index a46b06c4b5..3193c79220 100644
--- a/AK/Format.h
+++ b/AK/Format.h
@@ -384,13 +384,29 @@ void outln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... par
inline void outln() { outln(stdout); }
+# define outln_if(flag, fmt, ...) \
+ do { \
+ if constexpr (flag) \
+ outln(fmt, ##__VA_ARGS__); \
+ } while (0)
+
template<typename... Parameters>
-void warn(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) { out(stderr, move(fmtstr), parameters...); }
+void warn(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters)
+{
+ out(stderr, move(fmtstr), parameters...);
+}
template<typename... Parameters>
void warnln(CheckedFormatString<Parameters...>&& fmtstr, const Parameters&... parameters) { outln(stderr, move(fmtstr), parameters...); }
inline void warnln() { outln(stderr); }
+
+# define warnln_if(flag, fmt, ...) \
+ do { \
+ if constexpr (flag) \
+ outln(fmt, ##__VA_ARGS__); \
+ } while (0)
+
#endif
void vdbgln(StringView fmtstr, TypeErasedFormatParams);