~stacyharper/bonsai

e1c6dd0c1aea7c45a0ab6ecfdf635035847be4b1 — Stacy Harper 12 days ago 2941af7
Verbose log in stdout
2 files changed, 20 insertions(+), 0 deletions(-)

M cmd/bonsaid/logging.ha
M cmd/bonsaid/main.ha
M cmd/bonsaid/logging.ha => cmd/bonsaid/logging.ha +18 -0
@@ 1,6 1,7 @@

use fmt;
use log;
use os;

fn null_logger_println(logger: *log::logger, fields: fmt::formattable...) void = {
	return;


@@ 16,3 17,20 @@ fn null_logger() log::logger = {
		printfln = &null_logger_printfln,
	};
};

fn stdout_logger_println(logger: *log::logger, fields: fmt::formattable...) void = {
	fmt::fprintln(os::stdout, fields...)!;
	return;
};

fn stdout_logger_printfln(logger: *log::logger, fmt: str, fields: fmt::field...) void = {
	fmt::fprintfln(os::stdout, fmt, fields...)!;
	return;
};

fn stdout_logger() log::logger = {
	return log::logger {
		println = &stdout_logger_println,
		printfln = &stdout_logger_printfln,
	};
};

M cmd/bonsaid/main.ha => cmd/bonsaid/main.ha +2 -0
@@ 39,6 39,8 @@ export fn main() void = {

	if (verbose == false) {
		log::setlogger(&null_logger());
	} else {
		log::setlogger(&stdout_logger());
	};

	if (json_file_path is void) {