diff options
author | bptato <nincsnevem662@gmail.com> | 2023-05-01 09:48:56 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-05-01 09:48:56 +0200 |
commit | e0a8b27068ac8fc61a243bae685c23a14976f619 (patch) | |
tree | 61b9f50aeeb0a35c7ecab7dc87db93461d1b3860 /src/utils | |
parent | 90d10281be21c174e0f1528a7d893e126c78a405 (diff) | |
download | chawan-e0a8b27068ac8fc61a243bae685c23a14976f619.tar.gz |
Add elog
Like eprint, but writes to `a'
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/eprint.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/eprint.nim b/src/utils/eprint.nim index 1564142e..fab56464 100644 --- a/src/utils/eprint.nim +++ b/src/utils/eprint.nim @@ -20,3 +20,19 @@ func eprint*(s: varargs[string, `$`]) = {.cast(noSideEffect), cast(tags: []), ca o &= x o &= '\n' stderr.write(o) + +func elog*(s: varargs[string, `$`]) = {.cast(noSideEffect), cast(tags: []), cast(raises: []).}: + var f: File + if not open(f, "a", fmAppend): + return + var a = false + var o = "" + for x in s: + if not a: + a = true + else: + o &= ' ' + o &= x + o &= '\n' + f.write(o) + close(f) |