log.zig
log.zig copied to clipboard
Change API to reduce typing
With Zig 0.6.0, any functions "interfacing" with io.out_stream() via fmt.format() need to pass a literal struct with the format string. So if Logger.logDebug() is used without placeholders in the format string, then users must still pass an empty struct literal. This looks like Logger.logDebug("hello", .{});.
I propose typing be reduced in two ways:
- Remove the redundant
logbeforeDebugto allow the function to becomeLogger.Debug() - Add the
Debugffunction for use cases where formatting place holders are needed. The new function would look likeLogger.Debugf("hello {}\n", .{world});.
This will allow Logger.Debug("hi"); to continue to work as originally intended, but also give users the ability to use format strings when needed but also not have to type empty struct literals every time when format strings are not needed.
I will submit a PR for these changes for approval.
Thanks!