mirror of https://github.com/fairyglade/ly.git
Remove LogFile
This commit is contained in:
parent
6dcea64840
commit
17e87cb6f6
|
@ -8,7 +8,6 @@ res/config.ini contains all of the available config options and their default va
|
|||
|
||||
+ border\_fg has been introduced to change the color of the borders.
|
||||
+ term\_restore\_cursor\_cmd should restore the cursor to it's usual state.
|
||||
+ log\_path is used to store ly.log and ly.log.old for debugging purposes (pretty much nothing is logged currently).
|
||||
+ vi\_mode to enable vi keybindings.
|
||||
+ sleep\_key and sleep\_cmd.
|
||||
|
||||
|
@ -43,3 +42,4 @@ session_index = 0
|
|||
+ X Server PID is fetched from /tmp/X{d}.lock to be able to kill the process since it detaches.
|
||||
+ Non .desktop files are now ignored in sessions directory.
|
||||
+ PAM auth is now done in a child process. (Fixes some issues with logging out and back in).
|
||||
+ When ly receives SIGTERM, the terminal is now cleared.
|
||||
|
|
|
@ -22,7 +22,6 @@ hide_key_hints: bool = false,
|
|||
input_len: u8 = 34,
|
||||
lang: []const u8 = "en",
|
||||
load: bool = true,
|
||||
log_path: ?[]const u8 = null,
|
||||
margin_box_h: u8 = 2,
|
||||
margin_box_v: u8 = 1,
|
||||
max_desktop_len: u8 = 100,
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
const std = @import("std");
|
||||
|
||||
const LogFile = @This();
|
||||
|
||||
file: ?std.fs.File = null,
|
||||
writer: ?std.fs.File.Writer = null,
|
||||
start_time: i64 = 0,
|
||||
|
||||
pub fn init(log_path: ?[]const u8) LogFile {
|
||||
if (log_path == null or log_path.?.len == 0) return LogFile{};
|
||||
|
||||
const directory = std.fs.openDirAbsolute(log_path.?, std.fs.Dir.OpenDirOptions{}) catch return LogFile{};
|
||||
|
||||
directory.rename("ly.log", "ly.log.old") catch |e| {
|
||||
if (e != error.FileNotFound) return LogFile{};
|
||||
};
|
||||
|
||||
const createFlags = std.fs.File.CreateFlags{};
|
||||
const file = directory.createFile("ly.log", createFlags) catch return LogFile{};
|
||||
|
||||
return LogFile{
|
||||
.file = file,
|
||||
.writer = file.writer(),
|
||||
.start_time = std.time.milliTimestamp(),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: LogFile) void {
|
||||
if (self.file) |file| file.close();
|
||||
}
|
||||
|
||||
fn prettyPrint(self: LogFile, comptime log_level: std.log.Level, comptime format: []const u8, args: anytype) void {
|
||||
//if (comptime !std.log.logEnabled(log_level, .log_file)) return;
|
||||
const ms_since_start: f80 = @floatFromInt(std.time.milliTimestamp() - self.start_time);
|
||||
const log_time: f64 = @floatCast(ms_since_start / 1000);
|
||||
|
||||
if (self.writer) |writer| {
|
||||
writer.print("[{d:.2}s] " ++ "{s}: " ++ format ++ "\n", .{ log_time, log_level.asText() } ++ args) catch return;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn info(self: LogFile, comptime format: []const u8, args: anytype) void {
|
||||
self.prettyPrint(.info, format, args);
|
||||
}
|
||||
|
||||
pub fn debug(self: LogFile, comptime format: []const u8, args: anytype) void {
|
||||
self.prettyPrint(.debug, format, args);
|
||||
}
|
||||
|
||||
pub fn warn(self: LogFile, comptime format: []const u8, args: anytype) void {
|
||||
self.prettyPrint(.warn, format, args);
|
||||
}
|
||||
|
||||
pub fn err(self: LogFile, comptime format: []const u8, args: anytype) void {
|
||||
self.prettyPrint(.err, format, args);
|
||||
}
|
|
@ -14,7 +14,6 @@ const Config = @import("config/Config.zig");
|
|||
const ini = @import("config/ini.zig");
|
||||
const Lang = @import("config/Lang.zig");
|
||||
const Save = @import("config/Save.zig");
|
||||
const LogFile = @import("logger/LogFile.zig");
|
||||
const ViMode = @import("enums.zig").ViMode;
|
||||
const SharedError = @import("SharedError.zig");
|
||||
|
||||
|
@ -91,11 +90,6 @@ pub fn main() !void {
|
|||
lang = lang_ini.readToStruct(lang_path) catch Lang{};
|
||||
}
|
||||
|
||||
const logger = LogFile.init(config.log_path);
|
||||
defer logger.deinit();
|
||||
|
||||
logger.debug("Ly Started", .{});
|
||||
|
||||
// Initialize information line with host name
|
||||
var got_host_name = false;
|
||||
var host_name_buffer: []u8 = undefined;
|
||||
|
|
Loading…
Reference in New Issue