Commit graph

33 commits

Author SHA1 Message Date
asynts 74438e6fdc AK: Remove out() and warn(). 2020-11-09 16:21:29 +01:00
asynts 1319ad476d AK: Deprecate warn(). 2020-10-25 18:52:51 +01:00
asynts aa115fe27b AK: Add [[deprecated]] to out(). 2020-10-24 12:56:25 +02:00
asynts d5ffb51a83 AK: Don't add newline for outf/dbgf/warnf.
In the future all (normal) output should be written by any of the
following functions:

    out    (currently called new_out)
    outln
    dbg    (currently called new_dbg)
    dbgln
    warn   (currently called new_warn)
    warnln

However, there are still a ton of uses of the old out/warn/dbg in the
code base so the new functions are called new_out/new_warn/new_dbg. I am
going to rename them as soon as all the other usages are gone (this
might take a while.)

I also added raw_out/raw_dbg/raw_warn which don't do any escaping,
this should be useful if no formatting is required and if the input
contains tons of curly braces. (I am not entirely sure if this function
will stay, but I am adding it for now.)
2020-10-04 17:04:55 +02:00
asynts 6351a56d27 AK+Format: Do some housekeeping in the format implementation. 2020-10-02 20:48:19 +02:00
asynts 5ed15a49f2 AK: Add outf, warnf and dbgf. 2020-09-23 21:45:28 +02:00
asynts 0055a28710 AK: Replace LogStream operator for ReadonlyBytes with dump_bytes.
It wasn't actually possible to call

    const LogStream& operator<<(const LogStream&, ReadonlyBytes);

because it was shadowed by

    template<typename T>
    const LogStream& operator<<(const LogStream& stream, Span<T> span);

not sure how I didn't find this when I added the overload.

It would be possible to use SFINAE to disable the other overload,
however, I think it is better to use a different method entirely because
the output can be very verbose:

    void dump_bytes(ReadonlyBytes);
2020-09-10 14:15:02 +02:00
asynts cd2815ed87 AK: Add LogStream overload for ReadonlyBytes.
This is extremely useful for debugging.
2020-09-06 20:47:35 +02:00
asynts b011f87d34 AK: Add log stream operator overload for Span. 2020-09-06 12:54:45 +02:00
Ben Wiederhake 1ef26e0c09 AK: Provide off-switch for dbg() output 2020-08-30 09:43:49 +02:00
Tom 038dd9f30e AK: Serialize entire log statements
Prior to this, we wrote to the log every time the << operator
was used, which meant that only these parts of the log statement
were serialized. If the thread was preempted, or especially with
multiple CPUs the debug output was hard to decipher. Instead, we
buffer up the log statements. To avoid allocations we'll attempt
to use stack space, which covers most log statements.
2020-07-03 19:32:34 +02:00
Andreas Kling 21d5f4ada1 Kernel: Absorb LibBareMetal back into the kernel
This was supposed to be the foundation for some kind of pre-kernel
environment, but nobody is working on it right now, so let's move
everything back into the kernel and remove all the confusion.
2020-05-16 12:00:04 +02:00
Devashish Jaiswal cc01933840
AK: Declare LogStream::operator<<(const LogStream&, long) (#2155)
LogStream::operator<<(const LogStream&, long) was implemented in
AK/LogStream.cpp but the declaration was missing from the header.
2020-05-08 09:35:23 +02:00
Andreas Kling 3bbc2c7300 AK: Add LogStream operator<< overloads for float and double 2020-04-12 19:23:39 +02:00
Andreas Kling 0d48fb9a87 AK: Add out() and warn() streams that forward to stdout and stderr
Our C++ code generator tools have been relying on host-side dbg() being
forwarded to stdout until now. Now they use out() instead.

Hopefully this will make it easier and more enticing to use streams in
userspace programs as well. :^)
2020-04-06 10:49:27 +02:00
Andreas Kling c4a6d6ae9f AK: Add FlyString::to_lowercase() and LogStream operator<<(FlyString) 2020-03-22 19:07:02 +01:00
Andreas Kling 783c99516a AK: LogStream should handle being passed a null const char* 2020-03-04 21:04:06 +01:00
Liav A 9440c45d6e AK: Add support for Kernel Log Stream 2020-03-02 22:23:39 +01:00
Andreas Kling 3bbf4610d2 AK: Add a forward declaration header
You can now #include <AK/Forward.h> to get most of the AK types as
forward declarations.

Header dependency explosion is one of the main contributors to compile
times at the moment, so this is a step towards smaller include graphs.
2020-02-14 23:31:18 +01:00
Liav A 8bdb08c354 AK: Apply changes for the Bootstrapper environment 2020-02-09 19:38:17 +01:00
Andreas Kling be0034d2ca AK: Break LogStream::operator<< overloads into i/l/ll and u/ul/ull 2020-02-05 19:13:44 +01:00
joshua stein dc93ed4368 AK: Add support for 64-bit size_t 2020-02-05 18:39:45 +01:00
Andreas Kling 94ca55cefd Meta: Add license header to source files
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.

For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.

Going forward, all new source files should include a license header.
2020-01-18 09:45:54 +01:00
Andreas Kling 44bc4008b7 Build: Get rid of the USERLAND define
Let's simplify things. There is now only KERNEL.
To see if you're on Serenity, check if __serenity__ is defined.
2019-12-20 22:59:11 +01:00
Andreas Kling 1726c17d0d AK: Handle LogStream operator<<(size_t)
This has been an annoyingly missing feature for some time.
2019-12-09 17:51:21 +01:00
Andreas Kling 2ad0ec325a AK: Get rid of TStyle (output styling helper for LogStream)
This didn't end up getting used, so let's get rid of it.
2019-11-06 11:37:03 +01:00
Andreas Kling 5122caf9a8 LogStream: Prefix userspace dbg() output with "ProcessName(PID): "
Using the new get_process_name() syscall, we can automatically prefix
all userspace debug logging.

Hopefully this is more helpful than annoying. We'll find out! :^)
2019-08-15 20:55:45 +02:00
Andreas Kling 9fb2a65716 AK: Rename ValueRestorer => ScopedValueRollback.
Qt had a pretty good name for this concept, so let's steal it. :^)
2019-07-25 15:15:46 +02:00
Andreas Kling 0846986cac LogStream: Preserve errno for the lifetime of a LogStream object. 2019-07-25 07:00:33 +02:00
Andreas Kling af81645a2a Kernel+LibC: Add a dbgputstr() syscall for sending strings to debug output.
This is very handy for the DebugLogStream implementation, among others. :^)
2019-07-21 21:43:37 +02:00
Andreas Kling 8075ba5064 LogStream: Add a simple-ish mechanism for colorizing and styling output.
Meet TStyle. It allows you to write things like this:

    dbg() << TStyle(TStyle::Red, TStyle::Bold) << "Hello, friends!";

Any style used will be reset along with the newline emitted when the dbg()
temporary goes out of scope. :^)

This can definitely be improved, but I think it's a decent place to start.
2019-07-15 20:22:30 +02:00
Andreas Kling 1b013ba699 AK: Move some of LogStream out of line & add overloads for smart pointers. 2019-07-04 07:05:58 +02:00
Andreas Kling 05cc59921a AK: Start fleshing out LogStream, a type-aware logging mechanism.
The first implementation class is DebugLogStream, which can be used like so:

    dbg() << "Hello friends, I am " << m_years << " years old!";

Note that it will automatically print a newline when the object created by
dbg() goes out of scope.

This API will grow and evolve, so let's see what we end up with :^)
2019-07-04 06:43:30 +02:00