mach: use std.log.(scope) instead of std.debug.print

This commit is contained in:
Ali Chraghi 2022-09-03 22:03:49 +04:30 committed by Stephen Gutekanst
parent d8af6740c5
commit 194971586d
2 changed files with 11 additions and 11 deletions

View file

@ -84,7 +84,7 @@ pub const Platform = struct {
const instance = gpu.createInstance(null); const instance = gpu.createInstance(null);
if (instance == null) { if (instance == null) {
std.debug.print("mach: failed to create GPU instance\n", .{}); std.log.err("mach: failed to create GPU instance\n", .{});
std.process.exit(1); std.process.exit(1);
} }
const surface = util.createSurfaceForWindow(instance.?, window, comptime util.detectGLFWOptions()); const surface = util.createSurfaceForWindow(instance.?, window, comptime util.detectGLFWOptions());
@ -96,8 +96,8 @@ pub const Platform = struct {
.force_fallback_adapter = false, .force_fallback_adapter = false,
}, &response, util.requestAdapterCallback); }, &response, util.requestAdapterCallback);
if (response.?.status != .success) { if (response.?.status != .success) {
std.debug.print("mach: failed to create GPU adapter: {?s}\n", .{response.?.message}); std.log.err("mach: failed to create GPU adapter: {?s}\n", .{response.?.message});
std.debug.print("-> maybe try MACH_GPU_BACKEND=opengl ?\n", .{}); std.log.info("-> maybe try MACH_GPU_BACKEND=opengl ?\n", .{});
std.process.exit(1); std.process.exit(1);
} }
@ -108,7 +108,7 @@ pub const Platform = struct {
std.log.err("no backend found for {s} adapter", .{props.adapter_type.name()}); std.log.err("no backend found for {s} adapter", .{props.adapter_type.name()});
std.process.exit(1); std.process.exit(1);
} }
std.debug.print("mach: found {s} backend on {s} adapter: {s}, {s}\n", .{ std.log.info("mach: found {s} backend on {s} adapter: {s}, {s}\n", .{
props.backend_type.name(), props.backend_type.name(),
props.adapter_type.name(), props.adapter_type.name(),
props.name, props.name,
@ -124,7 +124,7 @@ pub const Platform = struct {
}) else null, }) else null,
}); });
if (device == null) { if (device == null) {
std.debug.print("mach: failed to create GPU device\n", .{}); std.log.err("mach: failed to create GPU device\n", .{});
std.process.exit(1); std.process.exit(1);
} }
@ -410,7 +410,7 @@ pub const Platform = struct {
// TODO: In the future we shouldn't hit this because we'll provide backup // TODO: In the future we shouldn't hit this because we'll provide backup
// custom cursors. // custom cursors.
// See https://github.com/hexops/mach/pull/352 for more info // See https://github.com/hexops/mach/pull/352 for more info
std.debug.print("mach: setMouseCursor: {s} not yet supported\n", .{cursor}); std.log.warn("mach: setMouseCursor: {s} not yet supported\n", .{cursor});
} }
} }
@ -588,7 +588,7 @@ pub const Platform = struct {
/// Default GLFW error handling callback /// Default GLFW error handling callback
fn errorCallback(error_code: glfw.Error, description: [:0]const u8) void { fn errorCallback(error_code: glfw.Error, description: [:0]const u8) void {
std.debug.print("glfw: {}: {s}\n", .{ error_code, description }); std.log.err("glfw: {}: {s}\n", .{ error_code, description });
} }
}; };

View file

@ -6,10 +6,10 @@ const objc = @import("objc_message.zig");
pub inline fn printUnhandledErrorCallback(_: void, typ: gpu.ErrorType, message: [*:0]const u8) void { pub inline fn printUnhandledErrorCallback(_: void, typ: gpu.ErrorType, message: [*:0]const u8) void {
switch (typ) { switch (typ) {
.validation => std.debug.print("gpu: validation error: {s}\n", .{message}), .validation => std.log.err("gpu: validation error: {s}\n", .{message}),
.out_of_memory => std.debug.print("gpu: out of memory: {s}\n", .{message}), .out_of_memory => std.log.err("gpu: out of memory: {s}\n", .{message}),
.device_lost => std.debug.print("gpu: device lost: {s}\n", .{message}), .device_lost => std.log.err("gpu: device lost: {s}\n", .{message}),
.unknown => std.debug.print("gpu: unknown error: {s}\n", .{message}), .unknown => std.log.err("gpu: unknown error: {s}\n", .{message}),
else => unreachable, else => unreachable,
} }
std.os.exit(1); std.os.exit(1);