1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:57:35 +00:00

Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)

Good-bye LogStream. Long live AK::Format!
This commit is contained in:
Andreas Kling 2021-03-12 17:29:37 +01:00
parent 423ed53396
commit ef1e5db1d0
209 changed files with 164 additions and 837 deletions

View file

@ -25,12 +25,13 @@
*/
#include <AK/Debug.h>
#include <AK/LogStream.h>
#include <AK/Format.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/internals.h>
#include <sys/mman.h>
#include <unistd.h>
extern "C" {

View file

@ -29,13 +29,11 @@
#include <AK/RefPtr.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibELF/DynamicLoader.h>
#include <assert.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// NOTE: The string here should never include a trailing newline (according to POSIX)
String g_dlerror_msg;

View file

@ -24,7 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/LogStream.h>
#include <assert.h>
#include <locale.h>
#include <stdio.h>

View file

@ -26,7 +26,6 @@
#include <AK/Debug.h>
#include <AK/InlineLinkedList.h>
#include <AK/LogStream.h>
#include <AK/ScopedValueRollback.h>
#include <AK/Vector.h>
#include <LibELF/AuxiliaryVector.h>

View file

@ -25,8 +25,8 @@
*/
#include <AK/Assertions.h>
#include <AK/Format.h>
#include <AK/GenericLexer.h>
#include <AK/LogStream.h>
#include <AK/StdLibExtras.h>
#include <ctype.h>
#include <stdarg.h>

View file

@ -1048,10 +1048,9 @@ void dbgputch(char ch)
syscall(SC_dbgputch, ch);
}
int dbgputstr(const char* characters, ssize_t length)
void dbgputstr(const char* characters, size_t length)
{
int rc = syscall(SC_dbgputstr, characters, length);
__RETURN_WITH_ERRNO(rc, rc, -1);
syscall(SC_dbgputstr, characters, length);
}
char* tmpnam(char*)

View file

@ -94,7 +94,7 @@ int vsnprintf(char* buffer, size_t, const char* fmt, va_list) __attribute__((for
int fprintf(FILE*, const char* fmt, ...) __attribute__((format(printf, 2, 3)));
int printf(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
void dbgputch(char);
int dbgputstr(const char*, ssize_t);
void dbgputstr(const char*, size_t);
int sprintf(char* buffer, const char* fmt, ...) __attribute__((format(printf, 2, 3)));
int snprintf(char* buffer, size_t, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
int putchar(int ch);

View file

@ -24,7 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/LogStream.h>
#include <errno.h>
#include <sys/ptrace.h>
#include <syscall.h>

View file

@ -25,7 +25,6 @@
*/
#include <AK/Assertions.h>
#include <AK/LogStream.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>

View file

@ -27,7 +27,6 @@
#include <AK/Array.h>
#include <AK/Assertions.h>
#include <AK/BinarySearch.h>
#include <AK/LogStream.h>
#include <AK/MemoryStream.h>
#include <LibCompress/Deflate.h>

View file

@ -29,6 +29,7 @@
#include <AK/ScopeGuard.h>
#include <LibCore/Account.h>
#include <LibCore/File.h>
#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>

View file

@ -26,7 +26,7 @@
#include "Command.h"
#include <AK/ByteBuffer.h>
#include <AK/LogStream.h>
#include <AK/Format.h>
#include <AK/ScopeGuard.h>
#include <LibCore/File.h>
#include <fcntl.h>

View file

@ -255,9 +255,4 @@ bool DateTime::is_before(const String& other) const
return __builtin_strcasecmp(now_string.characters(), other.characters()) < 0;
}
const LogStream& operator<<(const LogStream& stream, const DateTime& value)
{
return stream << value.to_string();
}
}

View file

@ -69,6 +69,4 @@ private:
unsigned m_second { 0 };
};
const LogStream& operator<<(const LogStream&, const DateTime&);
}

View file

@ -27,6 +27,7 @@
#include <AK/Vector.h>
#include <LibCore/DirIterator.h>
#include <errno.h>
#include <unistd.h>
namespace Core {

View file

@ -40,6 +40,7 @@
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
namespace Core {

View file

@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
namespace Core {

View file

@ -262,9 +262,4 @@ void Object::register_property(const String& name, Function<JsonValue()> getter,
m_properties.set(name, make<Property>(name, move(getter), move(setter)));
}
const LogStream& operator<<(const LogStream& stream, const Object& object)
{
return stream << object.class_name() << '{' << &object << '}';
}
}

View file

@ -223,8 +223,6 @@ T* Object::find_descendant_of_type_named(const String& name) requires IsBaseOf<O
return found_child;
}
const LogStream& operator<<(const LogStream&, const Object&);
#define REGISTER_INT_PROPERTY(property_name, getter, setter) \
register_property( \
property_name, \

View file

@ -1,36 +0,0 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <LibCore/SocketAddress.h>
namespace Core {
const LogStream& operator<<(const LogStream& stream, const SocketAddress& value)
{
return stream << value.to_string();
}
}

View file

@ -110,8 +110,6 @@ private:
String m_local_address;
};
const LogStream& operator<<(const LogStream&, const SocketAddress&);
}
template<>

View file

@ -27,7 +27,6 @@
#pragma once
#include <AK/Debug.h>
#include <AK/LogStream.h>
#include <AK/StdLibExtras.h>
#include <errno.h>
#include <string.h>

View file

@ -31,6 +31,7 @@
#include <LibCore/TCPSocket.h>
#include <stdio.h>
#include <sys/socket.h>
#include <unistd.h>
#ifndef SOCK_NONBLOCK
# include <fcntl.h>

View file

@ -29,6 +29,7 @@
#include <LibCore/Notifier.h>
#include <LibCore/UDPServer.h>
#include <LibCore/UDPSocket.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>

View file

@ -25,7 +25,6 @@
*/
#include "AST.h"
#include "AK/LogStream.h"
namespace Cpp {

View file

@ -29,7 +29,6 @@
#endif
#include "Parser.h"
#include "AK/LogStream.h"
#include "AST.h"
#include <AK/Debug.h>
#include <AK/ScopeGuard.h>

View file

@ -141,20 +141,6 @@ struct SignedDivisionResult {
}
inline const LogStream&
operator<<(const LogStream& stream, const Crypto::SignedBigInteger value)
{
if (value.is_invalid()) {
stream << "Invalid BigInt";
return stream;
}
if (value.is_negative())
stream << "-";
stream << value.unsigned_value();
return stream;
}
inline Crypto::SignedBigInteger
operator""_sbigint(const char* string, size_t length)
{

View file

@ -27,7 +27,6 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/LogStream.h>
#include <AK/Span.h>
#include <AK/String.h>
#include <AK/Types.h>
@ -131,19 +130,6 @@ struct UnsignedDivisionResult {
}
inline const LogStream&
operator<<(const LogStream& stream, const Crypto::UnsignedBigInteger& value)
{
if (value.is_invalid()) {
stream << "Invalid BigInt";
return stream;
}
for (int i = value.length() - 1; i >= 0; --i) {
stream << value.words()[i] << "|";
}
return stream;
}
template<>
struct AK::Formatter<Crypto::UnsignedBigInteger> : Formatter<StringView> {
void format(FormatBuilder&, const Crypto::UnsignedBigInteger&);

View file

@ -26,7 +26,6 @@
#pragma once
#include <AK/LogStream.h>
#include <AK/Span.h>
#include <AK/Types.h>
#include <LibCrypto/Checksum/ChecksumFunction.h>

View file

@ -30,7 +30,6 @@
#include <AK/HashMap.h>
#include <AK/HashTable.h>
#include <AK/LexicalPath.h>
#include <AK/LogStream.h>
#include <AK/NonnullRefPtrVector.h>
#include <AK/ScopeGuard.h>
#include <LibC/mman.h>

View file

@ -40,6 +40,7 @@
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#ifndef __serenity__
static void* mmap_with_name(void* addr, size_t length, int prot, int flags, int fd, off_t offset, const char*)

View file

@ -28,7 +28,6 @@
#include <AK/MappedFile.h>
#include <AK/String.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibCore/StandardPaths.h>
#include <LibELF/Image.h>
@ -38,6 +37,7 @@
#include <LibGfx/Bitmap.h>
#include <LibGfx/PNGLoader.h>
#include <sys/stat.h>
#include <unistd.h>
namespace GUI {

View file

@ -39,11 +39,4 @@ Variant ModelIndex::data(ModelRole role) const
return model()->data(*this, role);
}
const LogStream& operator<<(const LogStream& stream, const ModelIndex& value)
{
if (value.internal_data())
return stream << String::formatted("ModelIndex({},{},{:p})", value.row(), value.column(), value.internal_data());
return stream << String::formatted("ModelIndex({},{})", value.row(), value.column());
}
}

View file

@ -76,8 +76,6 @@ private:
void* m_internal_data { nullptr };
};
const LogStream& operator<<(const LogStream&, const ModelIndex&);
}
namespace AK {

View file

@ -26,7 +26,6 @@
#pragma once
#include <AK/LogStream.h>
#include <AK/String.h>
namespace GUI {
@ -57,13 +56,6 @@ private:
size_t m_column { 0xffffffff };
};
inline const LogStream& operator<<(const LogStream& stream, const TextPosition& value)
{
if (!value.is_valid())
return stream << "GUI::TextPosition(Invalid)";
return stream << String::formatted("({},{})", value.line(), value.column());
}
}
template<>

View file

@ -26,7 +26,6 @@
#pragma once
#include <AK/LogStream.h>
#include <LibGUI/TextPosition.h>
namespace GUI {
@ -85,13 +84,6 @@ private:
TextPosition m_end;
};
inline const LogStream& operator<<(const LogStream& stream, const TextRange& value)
{
if (!value.is_valid())
return stream << "GUI::TextRange(Invalid)";
return stream << value.start() << '-' << value.end();
}
}
template<>

View file

@ -24,7 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/LogStream.h>
#include <AK/Optional.h>
#include <LibGfx/AffineTransform.h>
#include <LibGfx/Rect.h>
@ -158,18 +157,4 @@ IntRect AffineTransform::map(const IntRect& rect) const
return enclosing_int_rect(map(FloatRect(rect)));
}
const LogStream& operator<<(const LogStream& stream, const AffineTransform& value)
{
if (value.is_identity())
return stream << "{ Identity }";
return stream << "{ "
<< value.a() << ", "
<< value.b() << ", "
<< value.c() << ", "
<< value.d() << ", "
<< value.e() << ", "
<< value.f() << " }";
}
}

View file

@ -27,7 +27,6 @@
#pragma once
#include <AK/Forward.h>
#include <AK/LogStream.h>
#include <LibGfx/Forward.h>
namespace Gfx {
@ -76,6 +75,4 @@ private:
float m_values[6] { 0 };
};
const LogStream& operator<<(const LogStream&, const AffineTransform&);
}

View file

@ -328,10 +328,6 @@ Optional<Color> Color::from_string(const StringView& string)
return Color(r.value(), g.value(), b.value(), a.value());
}
const LogStream& operator<<(const LogStream& stream, Color value)
{
return stream << value.to_string();
}
}
bool IPC::encode(IPC::Encoder& encoder, const Color& color)

View file

@ -404,8 +404,6 @@ inline constexpr Color::Color(NamedColor named)
m_value = 0xff000000 | (rgb.r << 16) | (rgb.g << 8) | rgb.b;
}
const LogStream& operator<<(const LogStream&, Color);
}
using Gfx::Color;

View file

@ -212,9 +212,4 @@ private:
Optional<Gfx::FloatRect> m_bounding_box;
};
inline const LogStream& operator<<(const LogStream& stream, const Path& path)
{
return stream << path.to_string();
}
}

View file

@ -228,12 +228,6 @@ private:
T m_y { 0 };
};
template<typename T>
const LogStream& operator<<(const LogStream& stream, const Point<T>& point)
{
return stream << point.to_string();
}
using IntPoint = Point<int>;
using FloatPoint = Point<float>;

View file

@ -478,12 +478,6 @@ private:
Size<T> m_size;
};
template<typename T>
const LogStream& operator<<(const LogStream& stream, const Rect<T>& rect)
{
return stream << rect.to_string();
}
using IntRect = Rect<int>;
using FloatRect = Rect<float>;

View file

@ -150,12 +150,6 @@ private:
T m_height { 0 };
};
template<typename T>
const LogStream& operator<<(const LogStream& stream, const Gfx::Size<T>& size)
{
return stream << size.to_string();
}
using IntSize = Size<int>;
using FloatSize = Size<float>;

View file

@ -34,9 +34,4 @@ String Triangle::to_string() const
return String::formatted("({},{},{})", m_a, m_b, m_c);
}
const LogStream& operator<<(const LogStream& stream, const Triangle& value)
{
return stream << value.to_string();
}
}

View file

@ -76,6 +76,4 @@ private:
IntPoint m_c;
};
const LogStream& operator<<(const LogStream&, const Triangle&);
}

View file

@ -30,6 +30,7 @@
#include <AK/GenericLexer.h>
#include <AK/JsonObject.h>
#include <AK/ScopeGuard.h>
#include <AK/ScopedValueRollback.h>
#include <AK/StringBuilder.h>
#include <AK/Utf32View.h>
#include <AK/Utf8View.h>
@ -39,6 +40,7 @@
#include <LibCore/File.h>
#include <LibCore/Notifier.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <sys/ioctl.h>

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/ScopedValueRollback.h>
#include <AK/StringBuilder.h>
#include <AK/TemporaryChange.h>
#include <LibLine/Editor.h>

View file

@ -27,7 +27,6 @@
#include "RegexLexer.h"
#include <AK/Assertions.h>
#include <AK/Debug.h>
#include <AK/LogStream.h>
#include <stdio.h>
namespace regex {

View file

@ -33,6 +33,7 @@
#include <LibCrypto/ASN1/PEM.h>
#include <LibCrypto/PK/Code/EMSA_PSS.h>
#include <LibTLS/TLSv12.h>
#include <errno.h>
#ifndef SOCK_NONBLOCK
# include <sys/ioctl.h>

View file

@ -26,7 +26,6 @@
#include "AK/ByteBuffer.h"
#include <AK/Checked.h>
#include <AK/LogStream.h>
#include <AK/Utf32View.h>
#include <AK/Utf8View.h>
#include <LibCore/File.h>

View file

@ -24,7 +24,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/LogStream.h>
#include <LibTar/TarStream.h>
namespace Tar {

View file

@ -173,9 +173,4 @@ private:
float m_value { 0 };
};
inline const LogStream& operator<<(const LogStream& stream, const Length& value)
{
return stream << value.to_string();
}
}

View file

@ -30,6 +30,7 @@
#include <LibWeb/Dump.h>
#include <LibWeb/InProcessWebView.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <unistd.h>
int main(int argc, char** argv)
{