mod(options): build options to log to stderr and/or a file
All checks were successful
Run Tests / test (push) Successful in 43s
Run Tests / lint (push) Successful in 39s

NOTE: file logging will not work correctly yet due to opening files
appending using the std is currently not implemented (as of zig version
0.13.0)!
This commit is contained in:
2024-08-29 16:36:58 +02:00
parent b03c770b59
commit 7889a6ec7a
3 changed files with 46 additions and 15 deletions

View File

@@ -6,9 +6,13 @@ const std = @import("std");
pub fn build(b: *std.Build) void {
// build options to customize the log message formating
const include_timestamp = b.option(bool, "timestamp", "Enable inclusion of timestamps in log messages (default: true)") orelse true;
const stderr = b.option(bool, "stderr", "Print all log messages to stderr (default: true)") orelse true;
const file = b.option([]const u8, "file", "Print all log messages to the provided file.") orelse "";
const options = b.addOptions();
options.addOption(bool, "timestamp", include_timestamp);
options.addOption(bool, "stderr", stderr);
options.addOption([]const u8, "file", file);
const options_module = options.createModule();