~mrms/logsum

8bd5e42677cda5be2837cff23897552cf57aba42 — Marek Ma┼íkarinec 2 months ago 0562fa5
Fix logs.um

Signed-off-by: Marek Maškarinec <marek@mrms.cz>
2 files changed, 8 insertions(+), 5 deletions(-)

A .gitignore
M logs.um
A .gitignore => .gitignore +2 -0
@@ 0,0 1,2 @@
log.txt
umbox

M logs.um => logs.um +6 -5
@@ 71,11 71,10 @@ fn (this: ^FileBackend) close*() {

//~~fn mkFileBackend
// Creates a `FileBackend`. If `rewrite` is false, the file will be appended.
fn mkFileBackend*(path: str, rewrite: bool = false): FileBackend {
fn mkFileBackend*(path: str, rewrite: bool = false): (FileBackend, std.Err) {
//~~
	return {
		std.fopen(path, rewrite ? "w" : "a")
	}
	f, err := std.fopen(path, rewrite ? "w" : "a")
	return { f }, err
}

var (


@@ 232,7 231,9 @@ fn main() {
	sus(TAG, "Suspicious log")
	err(TAG, "Error log")

	setBackend(mkFileBackend("log.txt", true))
	fb, e := mkFileBackend("log.txt", true)
	std.exitif(e)
	setBackend(fb)
	dbg("debug.um", "Debug log")
	dbg(TAG, "Debug log")
	inf(TAG, "Information log")