1const std = @import("std");
2const string = []const u8;
3const extras = @import("./lib.zig");
4
5pub fn LoggingWriter(comptime T: type, comptime scope: @EnumLiteral()) type {
6 return struct {
7 child_stream: T,
8
9 pub const Error = T.Error;
10 pub const Writer = std.io.Writer(Self, Error, write);
11
12 const Self = @This();
13
14 pub fn init(child_stream: T) Self {
15 return .{
16 .child_stream = child_stream,
17 };
18 }
19
20 pub fn writer(self: Self) Writer {
21 return .{ .context = self };
22 }
23
24 fn write(self: Self, bytes: []const u8) Error!usize {
25 std.log.scoped(scope).debug("{s}", .{bytes});
26 return self.child_stream.write(bytes);
27 }
28 };
29}