summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-10-08 13:26:16 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-09 20:52:17 +0200
commit7ae530fbc78d7593bd959f1869f5b65aed4c76c7 (patch)
tree91fe88681591ee56c9b36b8d0495053c7c5406f2 /AK
parentf3b4fbf01fdeef77cb732eb01e8f0944db9984b3 (diff)
downloadserenity-7ae530fbc78d7593bd959f1869f5b65aed4c76c7.zip
AK+Format: Remove new_dbg(dbg) and raw_dbg.
We are adding the process name as prefix and a newline as suffix to any message written to debug. Thus, the following doesn't make any sense: for (u8 byte : bytes) dbg("{:02x} ", byte); dbgln(); Which function call would put the prefix? This doesn't make any sense, thus these functions must go. The example above could be converted to: StringBuilder builder; for (u8 byte : bytes) builder.appendff("{:02x} ", byte); dbgln("{}", builder.build());
Diffstat (limited to 'AK')
-rw-r--r--AK/Format.cpp14
-rw-r--r--AK/Format.h11
2 files changed, 7 insertions, 18 deletions
diff --git a/AK/Format.cpp b/AK/Format.cpp
index 3f0f725a2e..689a66899f 100644
--- a/AK/Format.cpp
+++ b/AK/Format.cpp
@@ -605,12 +605,7 @@ void vwarn(StringView fmtstr, TypeErasedFormatParams params, bool newline)
}
#endif
-void raw_dbg(StringView string)
-{
- const auto retval = dbgputstr(string.characters_without_null_termination(), string.length());
- ASSERT(retval == 0);
-}
-void vdbg(StringView fmtstr, TypeErasedFormatParams params, bool newline)
+void vdbgln(StringView fmtstr, TypeErasedFormatParams params)
{
StringBuilder builder;
@@ -639,11 +634,12 @@ void vdbg(StringView fmtstr, TypeErasedFormatParams params, bool newline)
#endif
vformat(builder, fmtstr, params);
+ builder.append('\n');
- if (newline && !builder.is_empty())
- builder.append('\n');
+ const auto string = builder.build();
- raw_dbg(builder.to_string());
+ const auto retval = dbgputstr(string.characters(), string.length());
+ ASSERT(retval == 0);
}
template struct Formatter<unsigned char, void>;
diff --git a/AK/Format.h b/AK/Format.h
index 2b800111f1..4bd3a4f4d9 100644
--- a/AK/Format.h
+++ b/AK/Format.h
@@ -332,17 +332,12 @@ void warnln(const char* fmtstr, const Parameters&... parameters) { warnln(String
inline void warnln() { raw_out("\n"); }
#endif
-void vdbg(StringView fmtstr, TypeErasedFormatParams, bool newline = false);
-void raw_dbg(StringView string);
+void vdbgln(StringView fmtstr, TypeErasedFormatParams);
-// FIXME: Rename this function to 'dbg' when that name becomes avaliable.
template<typename... Parameters>
-void new_dbg(StringView fmtstr, const Parameters&... parameters) { vdbg(fmtstr, VariadicFormatParams { parameters... }); }
-template<typename... Parameters>
-void dbgln(StringView fmtstr, const Parameters&... parameters) { vdbg(fmtstr, VariadicFormatParams { parameters... }, true); }
+void dbgln(StringView fmtstr, const Parameters&... parameters) { vdbgln(fmtstr, VariadicFormatParams { parameters... }); }
template<typename... Parameters>
void dbgln(const char* fmtstr, const Parameters&... parameters) { dbgln(StringView { fmtstr }, parameters...); }
-inline void dbgln() { raw_dbg("\n"); }
template<typename T, typename = void>
struct HasFormatter : TrueType {
@@ -395,7 +390,5 @@ using AK::warnln;
#endif
using AK::dbgln;
-using AK::new_dbg;
-using AK::raw_dbg;
using AK::FormatIfSupported;