From 2a0719853e4d83e24e57292e8cd1da62021cf2a1 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Thu, 6 Jan 2022 14:01:20 -0800 Subject: [PATCH] add commented log function that will write to file --- src/download.zig | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/download.zig b/src/download.zig index 4638bcc..54e21d9 100644 --- a/src/download.zig +++ b/src/download.zig @@ -2,6 +2,41 @@ const builtin = @import("builtin"); const std = @import("std"); const Clipboard = @import("clipboard.zig"); +// Define root.log to override the std implementation +// pub fn log( +// comptime level: std.log.Level, +// comptime scope: @TypeOf(.EnumLiteral), +// comptime format: []const u8, +// args: anytype, +// ) void { +// // Ignore all non-error logging from sources other than +// // .my_project, .nice_library and .default +// const scope_prefix = "(" ++ switch (scope) { +// .my_project, .nice_library, .default => @tagName(scope), +// else => if (@enumToInt(level) <= @enumToInt(std.log.Level.err)) +// @tagName(scope) +// else +// return, +// } ++ "): "; +// +// const prefix = "[" ++ level.asText() ++ "] " ++ scope_prefix; +// +// // Print the message a file +// const lfile = std.fs.openFileAbsolute("d:\\yo", std.fs.File.OpenFlags{ +// .read = false, +// .write = true, +// }) catch return; +// lfile.seekFromEnd(0) catch return; +// defer lfile.close(); +// +// // Print the message to stderr, silently ignoring any errors +// std.debug.getStderrMutex().lock(); +// defer std.debug.getStderrMutex().unlock(); +// const stderr = std.io.getStdErr().writer(); +// nosuspend lfile.writer().print(prefix ++ format ++ "\n", args) catch return; +// nosuspend stderr.print(prefix ++ format ++ "\n", args) catch return; +// } + pub fn main() !u8 { var watch = false; var gpa = std.heap.GeneralPurposeAllocator(.{}){};