add(timestamp): timestamp build configuration option to add timestamps before log messages
This commit is contained in:
10
build.zig
10
build.zig
@@ -4,6 +4,14 @@ const std = @import("std");
|
||||
// declaratively construct a build graph that will be executed by an external
|
||||
// runner.
|
||||
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 options = b.addOptions();
|
||||
options.addOption(bool, "timestamp", include_timestamp);
|
||||
|
||||
const options_module = options.createModule();
|
||||
|
||||
// Standard target options allows the person running `zig build` to choose
|
||||
// what target to build for. Here we do not override the defaults, which
|
||||
// means any target is allowed, and the default is native. Other options
|
||||
@@ -21,7 +29,9 @@ pub fn build(b: *std.Build) void {
|
||||
.root_source_file = b.path("src/zlog.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = include_timestamp, // uses c std library <time.h>
|
||||
});
|
||||
zlog_module.addImport("build_options", options_module);
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "zlog",
|
||||
|
||||
Reference in New Issue
Block a user