hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

global.ha (602B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use io;
      5 use os;
      6 
      7 // The global logger instance.
      8 export let global: *logger = &_default;
      9 
     10 // Default logger that writes to [[os::stderr]].
     11 export const default: *logger = &_default;
     12 
     13 let _default: stdlogger = stdlogger {
     14 	println = &log_println,
     15 	printfln = &log_printfln,
     16 	sink = -1: io::file,
     17 };
     18 
     19 @init fn init() void = {
     20 	// XXX: Would be nice not to have to do this
     21 	_default.sink = os::stderr;
     22 };
     23 
     24 // Sets the global logger instance to the provided logger.
     25 export fn setlogger(log: *logger) void = {
     26 	global = log;
     27 };