hare

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

commit 24ba327413be2e1edd3d4174f1cf86fe16f90ce0
parent 92001a988574d8d0327db2616ce855fb399280cc
Author: Sebastian <sebastian@sebsite.pw>
Date:   Thu, 28 Apr 2022 17:27:42 -0400

log: add fatalf and lfatalf

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mlog/funcs.ha | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/log/funcs.ha b/log/funcs.ha @@ -21,8 +21,14 @@ export fn printfln(fmt: str, fields: fmt::field...) void = { lprintfln(global, fmt, fields...); }; +// Prints data to the log with a newline, then terminates the process. +export @noreturn fn lfatal(log: *logger, fields: fmt::formattable...) void = { + lprintln(log, fields...); + os::exit(1); +}; + // Formats and prints data to the log, then terminates the process. -export @noreturn fn lfatal( +export @noreturn fn lfatalf( log: *logger, fmt: str, fields: fmt::field... @@ -31,8 +37,14 @@ export @noreturn fn lfatal( os::exit(1); }; +// Prints data to the global log, then terminates the process. +export @noreturn fn fatal(fields: fmt::formattable...) void = { + lprintln(global, 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 = { +export @noreturn fn fatalf(fmt: str, fields: fmt::field...) void = { lprintfln(global, fmt, fields...); os::exit(1); };