diff options
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index 7a3f007..fd1c304 100644 --- a/src/main.zig +++ b/src/main.zig | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | pub const Buffer = @import("Buffer.zig"); | 1 | pub const Buffer = @import("Buffer.zig"); |
| 2 | pub const c = @import("c.zig"); | ||
| 2 | pub const conf = @import("es-config"); | 3 | pub const conf = @import("es-config"); |
| 3 | pub const Config = @import("Config.zig"); | 4 | pub const Config = @import("Config.zig"); |
| 4 | pub const Editor = @import("Editor.zig"); | 5 | pub const Editor = @import("Editor.zig"); |
| @@ -13,6 +14,7 @@ pub const search = @import("search.zig").search; | |||
| 13 | pub const StringBuilder = @import("StringBuilder.zig"); | 14 | pub const StringBuilder = @import("StringBuilder.zig"); |
| 14 | pub const Syntax = @import("Syntax.zig"); | 15 | pub const Syntax = @import("Syntax.zig"); |
| 15 | 16 | ||
| 17 | const builtin = @import("builtin"); | ||
| 16 | const std = @import("std"); | 18 | const std = @import("std"); |
| 17 | 19 | ||
| 18 | const Allocator = std.mem.Allocator; | 20 | const Allocator = std.mem.Allocator; |
| @@ -21,6 +23,12 @@ const GPA = std.heap.GeneralPurposeAllocator(.{}); | |||
| 21 | 23 | ||
| 22 | var log_file: ?File = null; | 24 | var log_file: ?File = null; |
| 23 | 25 | ||
| 26 | // TODO[zigbug]: Why isn't getpid defined for Darwin? | ||
| 27 | const getpid = switch (builtin.os.tag) { | ||
| 28 | .macos, .ios, .tvos, .watchos => c.getpid, | ||
| 29 | else => std.os.system.getpid, | ||
| 30 | }; | ||
| 31 | |||
| 24 | pub fn log( | 32 | pub fn log( |
| 25 | comptime level: std.log.Level, | 33 | comptime level: std.log.Level, |
| 26 | comptime scope: @TypeOf(.EnumLiteral), | 34 | comptime scope: @TypeOf(.EnumLiteral), |
| @@ -45,7 +53,7 @@ pub fn main() !void { | |||
| 45 | const log_file_name = try std.fmt.allocPrint( | 53 | const log_file_name = try std.fmt.allocPrint( |
| 46 | allocator, | 54 | allocator, |
| 47 | "/tmp/es.{}.log", | 55 | "/tmp/es.{}.log", |
| 48 | .{std.os.linux.getpid()}, | 56 | .{getpid()}, |
| 49 | ); | 57 | ); |
| 50 | defer { | 58 | defer { |
| 51 | std.log.info("Logs in {s}", .{log_file_name}); | 59 | std.log.info("Logs in {s}", .{log_file_name}); |