1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:37:46 +00:00

LibCore: Replace fprintf(stderr)/printf() with warnln()/out()

This commit is contained in:
Linus Groh 2021-05-31 15:00:38 +01:00
parent 1b81b63663
commit 303358220b
3 changed files with 8 additions and 9 deletions

View file

@ -149,12 +149,12 @@ void Object::stop_timer()
void Object::dump_tree(int indent)
{
for (int i = 0; i < indent; ++i) {
printf(" ");
out(" ");
}
printf("%s{%p}", class_name(), this);
out("{}{{{:p}}}", class_name(), this);
if (!name().is_null())
printf(" %s", name().characters());
printf("\n");
out(" {}", name());
outln();
for_each_child([&](auto& child) {
child.dump_tree(indent + 2);

View file

@ -11,7 +11,6 @@
#include <LibCore/File.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <pwd.h>
#include <stdio.h>
namespace Core {
@ -21,13 +20,13 @@ Optional<Vector<Core::ProcessStatistics>> ProcessStatisticsReader::get_all(RefPt
{
if (proc_all_file) {
if (!proc_all_file->seek(0, Core::SeekMode::SetPosition)) {
fprintf(stderr, "ProcessStatisticsReader: Failed to refresh /proc/all: %s\n", proc_all_file->error_string());
warnln("ProcessStatisticsReader: Failed to refresh /proc/all: {}", proc_all_file->error_string());
return {};
}
} else {
proc_all_file = Core::File::construct("/proc/all");
if (!proc_all_file->open(Core::OpenMode::ReadOnly)) {
fprintf(stderr, "ProcessStatisticsReader: Failed to open /proc/all: %s\n", proc_all_file->error_string());
warnln("ProcessStatisticsReader: Failed to open /proc/all: {}", proc_all_file->error_string());
return {};
}
}

View file

@ -106,7 +106,7 @@ bool Socket::connect(const SocketAddress& address)
auto dest_address = address.to_string();
bool fits = dest_address.copy_characters_to_buffer(saddr.sun_path, sizeof(saddr.sun_path));
if (!fits) {
fprintf(stderr, "Core::Socket: Failed to connect() to %s: Path is too long!\n", dest_address.characters());
warnln("Core::Socket: Failed to connect() to {}: Path is too long!", dest_address);
errno = EINVAL;
return false;
}
@ -139,7 +139,7 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
return true;
}
int saved_errno = errno;
fprintf(stderr, "Core::Socket: Failed to connect() to %s: %s\n", destination_address().to_string().characters(), strerror(saved_errno));
warnln("Core::Socket: Failed to connect() to {}: {}", destination_address().to_string(), strerror(saved_errno));
errno = saved_errno;
return false;
}