remove std.debug.print calls

This commit is contained in:
Emil Lerch 2025-12-09 11:59:11 -08:00
parent 07ce67f429
commit 669eb67a00
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -187,16 +187,24 @@ pub fn main() !void {
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var stdout_buffer: [1024]u8 = undefined;
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
const stdout = &stdout_writer.interface;
var stderr_buffer: [1024]u8 = undefined;
var stderr_writer = std.fs.File.stderr().writer(&stderr_buffer);
const stderr = &stderr_writer.interface;
var creds = try readCredentials(allocator);
defer creds.deinit();
std.debug.print("🔐 Authenticating...\n", .{});
try stdout.print("🔐 Authenticating...\n", .{});
const auth = try authenticate(allocator, creds.username, creds.password);
defer allocator.free(auth.id_token);
defer allocator.free(auth.user_uuid);
std.debug.print("✓ User UUID: {s}\n\n", .{auth.user_uuid});
try stdout.print("✓ User UUID: {s}\n\n", .{auth.user_uuid});
std.debug.print("📱 Fetching devices...\n", .{});
try stdout.print("📱 Fetching devices...\n", .{});
const result = try getDevices(allocator, auth.id_token, creds.username);
defer result.deinit();
@ -206,7 +214,7 @@ pub fn main() !void {
if (items.array.items.len > 0) {
if (items.array.items[0].object.get("devices")) |devices_obj| {
if (devices_obj.object.get("items")) |devices| {
std.debug.print("\n✓ Found {d} device(s):\n\n", .{devices.array.items.len});
try stdout.print("\n✓ Found {d} device(s):\n\n", .{devices.array.items.len});
for (devices.array.items) |device| {
const device_name = if (device.object.get("device_name")) |n| if (n == .string) n.string else "Unnamed" else "Unnamed";
@ -219,11 +227,11 @@ pub fn main() !void {
} else break :blk "N/A";
} else "N/A";
std.debug.print(" • {s}\n", .{device_name});
std.debug.print(" Thing Name: {s}\n", .{thing_name});
std.debug.print(" DSN: {s}\n", .{dsn});
std.debug.print(" Serial ID: {s}\n", .{serial_id});
std.debug.print(" Model: {s}\n\n", .{model});
try stdout.print(" • {s}\n", .{device_name});
try stdout.print(" Thing Name: {s}\n", .{thing_name});
try stdout.print(" DSN: {s}\n", .{dsn});
try stdout.print(" Serial ID: {s}\n", .{serial_id});
try stdout.print(" Model: {s}\n\n", .{model});
}
if (devices.array.items.len > 0) {
@ -236,47 +244,47 @@ pub fn main() !void {
if (serial_id) |sid| {
const device_name = if (device.object.get("device_name")) |n| if (n == .string) n.string else "Unnamed" else "Unnamed";
std.debug.print("🔍 Checking recirculation status for {s}...\n", .{device_name});
try stdout.print("🔍 Checking recirculation status for {s}...\n", .{device_name});
const status = try getRecirculationStatus(allocator, auth.id_token, sid);
defer status.deinit();
if (status.value.object.get("data")) |status_data| {
if (status_data.object.get("getDeviceShadow")) |shadow| {
std.debug.print("\nCurrent Shadow State:\n", .{});
try stdout.print("\nCurrent Shadow State:\n", .{});
if (shadow.object.get("heater_serial_number")) |v| {
if (v == .string) std.debug.print(" heater_serial_number: {s}\n", .{v.string});
if (v == .string) try stdout.print(" heater_serial_number: {s}\n", .{v.string});
}
if (shadow.object.get("set_recirculation_enabled")) |v| {
if (v == .bool) std.debug.print(" set_recirculation_enabled: {}\n", .{v.bool});
if (v == .bool) try stdout.print(" set_recirculation_enabled: {}\n", .{v.bool});
}
if (shadow.object.get("recirculation_enabled")) |v| {
if (v == .bool) std.debug.print(" recirculation_enabled: {}\n", .{v.bool});
if (v == .bool) try stdout.print(" recirculation_enabled: {}\n", .{v.bool});
}
if (shadow.object.get("recirculation_duration")) |v| {
if (v == .integer) std.debug.print(" recirculation_duration: {}\n", .{v.integer});
if (v == .integer) try stdout.print(" recirculation_duration: {}\n", .{v.integer});
}
if (shadow.object.get("set_domestic_temperature")) |v| {
if (v == .integer) std.debug.print(" set_domestic_temperature: {}\n", .{v.integer});
if (v == .integer) try stdout.print(" set_domestic_temperature: {}\n", .{v.integer});
}
if (shadow.object.get("operation_enabled")) |v| {
if (v == .bool) std.debug.print(" operation_enabled: {}\n", .{v.bool});
if (v == .bool) try stdout.print(" operation_enabled: {}\n", .{v.bool});
}
const recirc_enabled = if (shadow.object.get("recirculation_enabled")) |re| if (re == .bool) re.bool else false else false;
if (recirc_enabled) {
std.debug.print("\n✓ Recirculation is already active\n", .{});
try stdout.print("\n✓ Recirculation is already active\n", .{});
// Recirculation code commented out as requested
} else {
// Recirculation code would go here but not called during testing
std.debug.print("\n(Recirculation start function available but not called during testing)\n", .{});
try stdout.print("\n(Recirculation start function available but not called during testing)\n", .{});
}
}
}
} else {
std.debug.print("❌ No serial_id found for device\n", .{});
try stderr.print("❌ No serial_id found for device\n", .{});
return error.NoSerialId;
}
}
@ -288,6 +296,6 @@ pub fn main() !void {
} else {
const err_str = try std.fmt.allocPrint(allocator, "{}", .{result.value});
defer allocator.free(err_str);
std.debug.print("❌ Error: {s}\n", .{err_str});
try stderr.print("❌ Error: {s}\n", .{err_str});
}
}