@@ -11,6 +11,37 @@ const Handle = @import("message").Handle;
1111const build_options = @import ("build_options" );
1212
1313const version = "0.1.0" ;
14+ const git_hash = build_options .git_hash ;
15+
16+ pub const std_options : std.Options = .{
17+ .logFn = customLog ,
18+ };
19+
20+ fn customLog (
21+ comptime level : std.log.Level ,
22+ comptime scope : @TypeOf (.enum_literal ),
23+ comptime format : []const u8 ,
24+ args : anytype ,
25+ ) void {
26+ _ = scope ;
27+ const prefix = comptime switch (level ) {
28+ .err = > "ERROR" ,
29+ .warn = > "WARN " ,
30+ .info = > "INFO " ,
31+ .debug = > "DEBUG" ,
32+ };
33+
34+ // Get wall clock time
35+ const epoch = std .time .timestamp ();
36+ const es = std.time.epoch.EpochSeconds { .secs = @intCast (epoch ) };
37+ const day_secs = es .getDaySeconds ();
38+ const h = day_secs .getHoursIntoDay ();
39+ const m = day_secs .getMinutesIntoHour ();
40+ const s = day_secs .getSecondsIntoMinute ();
41+
42+ const stderr = std .fs .File .stderr ().deprecatedWriter ();
43+ nosuspend stderr .print ("{d:0>2}:{d:0>2}:{d:0>2} {s} [{s}-{s}] " ++ format ++ "\n " , .{h , m , s , prefix , version , git_hash } ++ args ) catch {};
44+ }
1445
1546var running : std .atomic .Value (bool ) = std .atomic .Value (bool ).init (true );
1647var signal_pipe : [2 ]posix.fd_t = .{ -1 , -1 };
@@ -60,6 +91,8 @@ pub fn main() !void {
6091 defer _ = gpa .deinit ();
6192 const allocator = gpa .allocator ();
6293
94+ std .log .info ("starting" , .{});
95+
6396 // Load config
6497 var config = Config .load (allocator );
6598 defer config .deinit ();
0 commit comments