diff options
author | konrad <konrad@serenityos.org> | 2023-01-08 05:33:48 +0100 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-01-18 22:58:42 +0100 |
commit | 9b12571a86bbc492527460781d98b1177d017ab0 (patch) | |
tree | 4268bd282e4cd2771566ff96a532c6c6e18a58c2 /AK/Format.cpp | |
parent | 5791072280aa4093159ae54f74ce80434650429b (diff) | |
download | serenity-9b12571a86bbc492527460781d98b1177d017ab0.zip |
AK: Unify kernel debug messages, avoid printing time if unavailable
Diffstat (limited to 'AK/Format.cpp')
-rw-r--r-- | AK/Format.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/AK/Format.cpp b/AK/Format.cpp index 9fa6f9e429..5f5b6cdfc7 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -886,10 +886,8 @@ void vdbgln(StringView fmtstr, TypeErasedFormatParams& params) #ifdef AK_OS_SERENITY # ifdef KERNEL - if (Kernel::Processor::is_initialized()) { - struct timespec ts = {}; - if (TimeManagement::is_initialized()) - ts = TimeManagement::the().monotonic_time(TimePrecision::Coarse).to_timespec(); + if (Kernel::Processor::is_initialized() && TimeManagement::is_initialized()) { + struct timespec ts = TimeManagement::the().monotonic_time(TimePrecision::Coarse).to_timespec(); if (Kernel::Thread::current()) { auto& thread = *Kernel::Thread::current(); builder.appendff("{}.{:03} \033[34;1m[#{} {}({}:{})]\033[0m: ", ts.tv_sec, ts.tv_nsec / 1000000, Kernel::Processor::current_id(), thread.process().name(), thread.pid().value(), thread.tid().value()); @@ -940,14 +938,17 @@ void vdmesgln(StringView fmtstr, TypeErasedFormatParams& params) # ifdef AK_OS_SERENITY struct timespec ts = {}; - if (TimeManagement::is_initialized()) + if (TimeManagement::is_initialized()) { ts = TimeManagement::the().monotonic_time(TimePrecision::Coarse).to_timespec(); - if (Kernel::Processor::is_initialized() && Kernel::Thread::current()) { - auto& thread = *Kernel::Thread::current(); - builder.appendff("{}.{:03} \033[34;1m[{}({}:{})]\033[0m: ", ts.tv_sec, ts.tv_nsec / 1000000, thread.process().name(), thread.pid().value(), thread.tid().value()); + if (Kernel::Processor::is_initialized() && Kernel::Thread::current()) { + auto& thread = *Kernel::Thread::current(); + builder.appendff("{}.{:03} \033[34;1m[{}({}:{})]\033[0m: ", ts.tv_sec, ts.tv_nsec / 1000000, thread.process().name(), thread.pid().value(), thread.tid().value()); + } else { + builder.appendff("{}.{:03} \033[34;1m[Kernel]\033[0m: ", ts.tv_sec, ts.tv_nsec / 1000000); + } } else { - builder.appendff("{}.{:03} \033[34;1m[Kernel]\033[0m: ", ts.tv_sec, ts.tv_nsec / 1000000); + builder.appendff("\033[34;1m[Kernel]\033[0m: "); } # endif |