mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
AK: Add outln_if and warnln_if
This uses the same gating mechanism as dbgln_if and should be equivalent to #define flag etc
This commit is contained in:
parent
2976311536
commit
2e11b2d35a
Notes:
sideshowbarker
2024-07-18 20:15:23 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/2e11b2d35a0 Pull-request: https://github.com/SerenityOS/serenity/pull/6357 Reviewed-by: https://github.com/linusg
1 changed files with 17 additions and 1 deletions
18
AK/Format.h
18
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);
|
||||
|
|
Loading…
Reference in a new issue