Is there a way to get a debug writer?

Is there a way to get a debug writer, similar to what std.debug.print does, but more generically as an entire writer? This is just to print information when I don’t have access to a writer. Something like this:

printSomeStuff(some_stuff, std.debug.writer)

or a similar pattern?

You probably want a writer to stderr?

var buf: [4096]u8 = undefined;
var stderr_file_writer = std.io.File.stderr().writer(io, &buf);
const stderr_wr = &stderr_file_writer.interface; // don't forget the &

Edit: What @hemisputnik below says is better.

Use std.debug.lockStderr to acquire stderr for writing, then use std.debug.unlockStderr to unlock it - this is what std.debug.print and the like use to write to stderr.

var stderr_buf: [64]u8 = undefined;
const locked_stderr = std.debug.lockStderr(&stderr_buf);
defer std.debug.unlockStderr();

Then either use locked_stderr.file_writer.interface,

locked_stderr.file_writer.interface.print("hello, {s}\n", .{"Ziggit"}) catch {};

or acquire a Io.Terminal, for more goodies such as access to text colour.

const terminal = locked_stderr.terminal();

terminal.setColor(.bright_black) catch {};
terminal.writer.print("hello, {s}\n", .{"Ziggit"}) catch {};
terminal.setColor(.reset) catch {};

std.debug.unlockStderr will call flush on the writer for you.