mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +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
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