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
Notes:
sideshowbarker
2024-07-17 02:23:25 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/d48c68cf3f Pull-request: https://github.com/SerenityOS/serenity/pull/19997 Reviewed-by: https://github.com/gmta ✅
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&);
|
||||
|
||||
void vdbg(StringView fmtstr, TypeErasedFormatParams&, bool newline = false);
|
||||
void dbgln();
|
||||
|
||||
#ifndef KERNEL
|
||||
void vout(FILE*, StringView fmtstr, TypeErasedFormatParams&, bool newline = false);
|
||||
|
||||
|
@ -593,13 +596,30 @@ inline void outln() { outln(stdout); }
|
|||
template<typename... 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...);
|
||||
}
|
||||
|
||||
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, ...) \
|
||||
do { \
|
||||
|
@ -609,8 +629,6 @@ inline void warnln() { outln(stderr); }
|
|||
|
||||
#endif
|
||||
|
||||
void vdbg(StringView fmtstr, TypeErasedFormatParams&, bool newline = false);
|
||||
|
||||
template<typename... Parameters>
|
||||
void dbg(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue