logging: Improve logging capabilities
notYuriy opened this issue · 2 comments
As of now, there are many log statements that make screen dirty.
The proposal is to add "trace" argument to os.log
or make a new function os.trace
that will be similar to os.log
but will have a "trace" argument. log
/trace
will then be used like this.
os.trace("range_alloc", "Allocated new range 0x{X} - -x{X}", .{range_start, range_end});
On startup, stivale2_main
would parse cmdline to find all enabled traces. If trace is enabled, thing will be logged, otherwise it trace
becomes a no-op.
The alternative is to define list of traces in compile-time config and checking if something should be printed at compile-time. This would remove all run-time overhead + stivale2 cmdline parser would not be needed. On the other hand, kernel would have to be recompiled every time we want to see output for some traces which is not really convinient in all cases. Additionally, we would need a stivale2 cmdline parser later on anyways
Alternatively: Have each trace configurable on/off from config.zig
at comptime
Turns out that the standard library provides all functionality needed under namespace std.log.*
, we just need to define a root log callback for logging functions to work.