mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:17:36 +00:00
AK: Automatically copy all warn/warnln logs to debug console
This is only enabled inside Serenity, as on Lagom, all out/warn/dbg logs go to the same console anyway.
This commit is contained in:
parent
d2766bd5fe
commit
d48c68cf3f
1 changed files with 22 additions and 4 deletions
26
AK/Format.h
26
AK/Format.h
|
@ -557,6 +557,9 @@ struct Formatter<nullptr_t> : Formatter<FlatPtr> {
|
||||||
|
|
||||||
ErrorOr<void> vformat(StringBuilder&, StringView fmtstr, TypeErasedFormatParams&);
|
ErrorOr<void> vformat(StringBuilder&, StringView fmtstr, TypeErasedFormatParams&);
|
||||||
|
|
||||||
|
void vdbg(StringView fmtstr, TypeErasedFormatParams&, bool newline = false);
|
||||||
|
void dbgln();
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
void vout(FILE*, StringView fmtstr, TypeErasedFormatParams&, bool newline = false);
|
void vout(FILE*, StringView fmtstr, TypeErasedFormatParams&, bool newline = false);
|
||||||
|
|
||||||
|
@ -593,13 +596,30 @@ inline void outln() { outln(stdout); }
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void warn(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
|
void warn(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
|
||||||
{
|
{
|
||||||
|
# ifdef AK_OS_SERENITY
|
||||||
|
VariadicFormatParams<AllowDebugOnlyFormatters::Yes, Parameters...> variadic_format_params { parameters... };
|
||||||
|
vdbg(fmtstr.view(), variadic_format_params, false);
|
||||||
|
# endif
|
||||||
out(stderr, move(fmtstr), parameters...);
|
out(stderr, move(fmtstr), parameters...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void warnln(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters) { outln(stderr, move(fmtstr), parameters...); }
|
void warnln(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
|
||||||
|
{
|
||||||
|
# ifdef AK_OS_SERENITY
|
||||||
|
VariadicFormatParams<AllowDebugOnlyFormatters::Yes, Parameters...> variadic_format_params { parameters... };
|
||||||
|
vdbg(fmtstr.view(), variadic_format_params, true);
|
||||||
|
# endif
|
||||||
|
outln(stderr, move(fmtstr), parameters...);
|
||||||
|
}
|
||||||
|
|
||||||
inline void warnln() { outln(stderr); }
|
inline void warnln()
|
||||||
|
{
|
||||||
|
# ifdef AK_OS_SERENITY
|
||||||
|
dbgln();
|
||||||
|
# endif
|
||||||
|
outln(stderr);
|
||||||
|
}
|
||||||
|
|
||||||
# define warnln_if(flag, fmt, ...) \
|
# define warnln_if(flag, fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -609,8 +629,6 @@ inline void warnln() { outln(stderr); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vdbg(StringView fmtstr, TypeErasedFormatParams&, bool newline = false);
|
|
||||||
|
|
||||||
template<typename... Parameters>
|
template<typename... Parameters>
|
||||||
void dbg(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
|
void dbg(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue