2019-09-06 15:34:26 +02:00
|
|
|
#include <AK/String.h>
|
2019-07-04 07:05:58 +02:00
|
|
|
#include <AK/LogStream.h>
|
|
|
|
|
#include <AK/StringView.h>
|
|
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
2019-07-08 09:22:22 +02:00
|
|
|
const LogStream& operator<<(const LogStream& stream, const String& value)
|
2019-07-04 07:05:58 +02:00
|
|
|
{
|
|
|
|
|
stream.write(value.characters(), value.length());
|
|
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-08 09:22:22 +02:00
|
|
|
const LogStream& operator<<(const LogStream& stream, const StringView& value)
|
2019-07-04 07:05:58 +02:00
|
|
|
{
|
2019-07-08 15:38:44 +02:00
|
|
|
stream.write(value.characters_without_null_termination(), value.length());
|
2019-07-04 07:05:58 +02:00
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-09 17:45:11 +01:00
|
|
|
const LogStream& operator<<(const LogStream& stream, i32 value)
|
2019-07-04 07:05:58 +02:00
|
|
|
{
|
|
|
|
|
return stream << String::number(value);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-09 17:45:11 +01:00
|
|
|
const LogStream& operator<<(const LogStream& stream, u32 value)
|
|
|
|
|
{
|
|
|
|
|
return stream << String::number(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const LogStream& operator<<(const LogStream& stream, u64 value)
|
2019-07-04 07:05:58 +02:00
|
|
|
{
|
|
|
|
|
return stream << String::number(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const LogStream& operator<<(const LogStream& stream, const void* value)
|
|
|
|
|
{
|
|
|
|
|
return stream << String::format("%p", value);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 22:56:42 +01:00
|
|
|
#if defined (__serenity__) && !defined(KERNEL)
|
2019-08-15 20:55:45 +02:00
|
|
|
static TriState got_process_name = TriState::Unknown;
|
|
|
|
|
static char process_name_buffer[256];
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
DebugLogStream dbg()
|
|
|
|
|
{
|
|
|
|
|
DebugLogStream stream;
|
2019-12-20 22:56:42 +01:00
|
|
|
#if defined (__serenity__) && !defined(KERNEL)
|
2019-08-15 20:55:45 +02:00
|
|
|
if (got_process_name == TriState::Unknown) {
|
|
|
|
|
if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0)
|
|
|
|
|
got_process_name = TriState::True;
|
|
|
|
|
else
|
|
|
|
|
got_process_name = TriState::False;
|
|
|
|
|
}
|
|
|
|
|
if (got_process_name == TriState::True)
|
2019-11-06 11:37:03 +01:00
|
|
|
stream << "\033[33;1m" << process_name_buffer << '(' << getpid() << ")\033[0m: ";
|
2019-08-15 20:55:45 +02:00
|
|
|
#endif
|
|
|
|
|
return stream;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-04 07:05:58 +02:00
|
|
|
}
|