diff --git a/src/auth.zig b/src/auth.zig index 86301a2..e7d6296 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -90,7 +90,8 @@ pub fn authenticate(allocator: std.mem.Allocator, log_writer: *std.Io.Writer, op child_pid = try std.posix.fork(); if (child_pid == 0) { - try log_writer.writeAll("starting session"); + try log_writer.writeAll("starting session\n"); + try log_writer.flush(); startSession(log_writer, allocator, options, tty_str, user_entry, handle, current_environment) catch |e| { shared_err.writeError(e); @@ -377,7 +378,7 @@ fn xauth(log_writer: *std.Io.Writer, allocator: std.mem.Allocator, display_name: const status = std.posix.waitpid(pid, 0); if (status.status != 0) { - try log_writer.print("xauth command failed with status {d}", .{status.status}); + try log_writer.print("xauth command failed with status {d}\n", .{status.status}); return error.XauthFailed; } } diff --git a/src/main.zig b/src/main.zig index 0733d1f..89f99d7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -229,6 +229,13 @@ pub fn main() !void { var log_buffer: [1024]u8 = undefined; var log_file_writer = log_file.writer(&log_buffer); + + // Seek to the end of the log file + if (could_open_log_file) { + const stat = try log_file.stat(); + try log_file_writer.seekTo(stat.size); + } + var log_writer = &log_file_writer.interface; // These strings only end up getting freed if the user quits Ly using Ctrl+C, which is fine since in the other cases @@ -787,7 +794,7 @@ pub fn main() !void { update = true; }, termbox.TB_KEY_ENTER => authenticate: { - try log_writer.writeAll("authenticating..."); + try log_writer.writeAll("authenticating...\n"); if (!config.allow_empty_password and password.text.items.len == 0) { // Let's not log this message for security reasons @@ -898,7 +905,7 @@ pub fn main() !void { password.clear(); try info_line.addMessage(lang.logout, config.bg, config.fg); - try log_writer.writeAll("logged out"); + try log_writer.writeAll("logged out\n"); } try std.posix.tcsetattr(std.posix.STDIN_FILENO, .FLUSH, tb_termios); @@ -955,6 +962,8 @@ pub fn main() !void { update = true; }, } + + try log_writer.flush(); } }