hare

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

commit 2796edd52f4cad7c57489cead7f0480c7dbbeb88
parent 15cf7e55cc1b988c5bfe2ebbd8af8808deb22e28
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 13 Apr 2022 17:19:58 +0200

log: add fatal, lfatal

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mlog/funcs.ha | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/log/funcs.ha b/log/funcs.ha @@ -1,4 +1,5 @@ use fmt; +use os; // Prints data to the log, with a newline. export fn lprintln(log: *logger, fields: fmt::formattable...) void = { @@ -19,3 +20,19 @@ export fn println(fields: fmt::formattable...) void = { export fn printfln(fmt: str, fields: fmt::field...) void = { lprintfln(global, fmt, fields...); }; + +// Formats and prints data to the log, then terminates the process. +export @noreturn fn lfatal( + log: *logger, + fmt: str, + fields: fmt::field... +) void = { + lprintfln(global, fmt, fields...); + os::exit(1); +}; + +// Formats and prints data to the global log, then terminates the process. +export @noreturn fn fatal(fmt: str, fields: fmt::field...) void = { + lprintfln(global, fmt, fields...); + os::exit(1); +};