@@ -15,9 +15,9 @@ const c = @cImport({
1515pub const Logger = struct {
1616 alloc : std.mem.Allocator ,
1717 name : []const u8 = "zippy" ,
18- use_color : bool = true ,
18+ useColor : bool = true ,
1919 file : ? std.fs.File = null ,
20- log_path : ? []const u8 = null ,
20+ logPath : ? []const u8 = null ,
2121 mutex : std.Thread.Mutex = .{},
2222
2323 // ANSI
@@ -29,32 +29,32 @@ pub const Logger = struct {
2929 const Cyan = "\x1b [36m" ;
3030
3131 pub fn init (alloc : std.mem.Allocator , name : []const u8 ) Logger {
32- const stderr_is_tty = std .posix .isatty (std .fs .File .stderr ().handle );
32+ const stderrIsTty = std .posix .isatty (std .fs .File .stderr ().handle );
3333 return .{
3434 .alloc = alloc ,
3535 .name = name ,
36- .use_color = stderr_is_tty ,
36+ .useColor = stderrIsTty ,
3737 .file = null ,
38- .log_path = null ,
38+ .logPath = null ,
3939 };
4040 }
4141
4242 pub fn enableFileLogging (self : * Logger , path : []const u8 ) ! void {
4343 const file = try std .fs .cwd ().createFile (path , .{ .read = true , .truncate = false , .exclusive = false , .mode = 0o644 });
4444 try file .seekFromEnd (0 );
4545 self .file = file ;
46- self .log_path = try self .alloc .dupe (u8 , path );
46+ self .logPath = try self .alloc .dupe (u8 , path );
4747 }
4848
4949 pub fn deinit (self : * Logger ) void {
5050 if (self .file ) | f | f .close ();
5151 self .file = null ;
52- if (self .log_path ) | p | self .alloc .free (p );
53- self .log_path = null ;
52+ if (self .logPath ) | p | self .alloc .free (p );
53+ self .logPath = null ;
5454 }
5555
5656 pub fn setColor (self : * Logger , enabled : bool ) void {
57- self .use_color = enabled ;
57+ self .useColor = enabled ;
5858 }
5959
6060 pub fn info (self : * Logger , comptime fmt : []const u8 , args : anytype ) ! void {
@@ -81,26 +81,26 @@ pub const Logger = struct {
8181 const ts = try formatTimestamp (a );
8282
8383 const tag = levelTag (level );
84- const tag_color = levelColor (level );
84+ const tagColor = levelColor (level );
8585
8686 const msg = try std .fmt .allocPrint (a , fmt , args );
8787
8888 const errf = std .fs .File .stderr ();
8989
90- const line = try if (self .use_color )
90+ const line = try if (self .useColor )
9191 std .fmt .allocPrint (
9292 a ,
9393 "{s}{s}{s} {s}[{s}]{s} {s}{s}{s} {s}\n " ,
94- .{ Dim , ts , Reset , tag_color , tag , Reset , Cyan , self .name , Reset , msg },
94+ .{ Dim , ts , Reset , tagColor , tag , Reset , Cyan , self .name , Reset , msg },
9595 )
9696 else
9797 std .fmt .allocPrint (a , "{s} [{s}] {s} {s}\n " , .{ ts , tag , self .name , msg });
9898
9999 try errf .writeAll (line );
100100
101101 if (self .file ) | _ | {
102- const plain_line = try std .fmt .allocPrint (a , "{s} [{s}] {s} {s}\n " , .{ ts , tag , self .name , msg });
103- self .writeRaw (plain_line );
102+ const plainLine = try std .fmt .allocPrint (a , "{s} [{s}] {s} {s}\n " , .{ ts , tag , self .name , msg });
103+ self .writeRaw (plainLine );
104104 }
105105 }
106106
0 commit comments