about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-05-01 09:48:56 +0200
committerbptato <nincsnevem662@gmail.com>2023-05-01 09:48:56 +0200
commite0a8b27068ac8fc61a243bae685c23a14976f619 (patch)
tree61b9f50aeeb0a35c7ecab7dc87db93461d1b3860 /src
parent90d10281be21c174e0f1528a7d893e126c78a405 (diff)
downloadchawan-e0a8b27068ac8fc61a243bae685c23a14976f619.tar.gz
Add elog
Like eprint, but writes to `a'
Diffstat (limited to 'src')
-rw-r--r--src/utils/eprint.nim16
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)