hare

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

funcs.ha (1515B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use fmt;
      5 use os;
      6 
      7 // Prints data to the log, with a newline.
      8 export fn lprintln(log: *logger, fields: fmt::formattable...) void = {
      9 	log.println(log, fields...);
     10 };
     11 
     12 // Formats and prints data to the log, with a newline.
     13 export fn lprintfln(log: *logger, fmt: str, fields: fmt::field...) void = {
     14 	log.printfln(log, fmt, fields...);
     15 };
     16 
     17 // Prints data to the global log, with a newline.
     18 export fn println(fields: fmt::formattable...) void = {
     19 	lprintln(global, fields...);
     20 };
     21 
     22 // Formats and prints data to the global log, with a newline.
     23 export fn printfln(fmt: str, fields: fmt::field...) void = {
     24 	lprintfln(global, fmt, fields...);
     25 };
     26 
     27 // Prints data to the log with a newline, then terminates the process.
     28 export fn lfatal(log: *logger, fields: fmt::formattable...) never = {
     29 	lprintln(log, fields...);
     30 	os::exit(255);
     31 };
     32 
     33 // Formats and prints data to the log with new line, then terminates the
     34 // process.
     35 export fn lfatalf(
     36 	log: *logger,
     37 	fmt: str,
     38 	fields: fmt::field...
     39 ) never = {
     40 	lprintfln(log, fmt, fields...);
     41 	os::exit(255);
     42 };
     43 
     44 // Prints data to the global log with new line, then terminates the process.
     45 export fn fatal(fields: fmt::formattable...) never = {
     46 	lprintln(global, fields...);
     47 	os::exit(255);
     48 };
     49 
     50 // Formats and prints data to the global log with new line, then terminates the
     51 // process.
     52 export fn fatalf(fmt: str, fields: fmt::field...) never = {
     53 	lprintfln(global, fmt, fields...);
     54 	os::exit(255);
     55 };