zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

std_options.zig (958B) - Raw


      1 /// The presence of this declaration allows the program to override certain behaviors of the standard library.
      2 /// For a full list of available options, see the documentation for `std.Options`.
      3 pub const std_options: std.Options = .{
      4     // By default, in safe build modes, the standard library will attach a segfault handler to the program to
      5     // print a helpful stack trace if a segmentation fault occurs. Here, we can disable this, or even enable
      6     // it in unsafe build modes.
      7     .enable_segfault_handler = true,
      8     // This is the logging function used by `std.log`.
      9     .logFn = myLogFn,
     10 };
     11 
     12 fn myLogFn(
     13     comptime level: std.log.Level,
     14     comptime scope: @Type(.enum_literal),
     15     comptime format: []const u8,
     16     args: anytype,
     17 ) void {
     18     // We could do anything we want here!
     19     // ...but actually, let's just call the default implementation.
     20     std.log.defaultLog(level, scope, format, args);
     21 }
     22 
     23 const std = @import("std");
     24 
     25 // syntax