aboutsummaryrefslogtreecommitdiff
path: root/examples/log/log.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-06 14:47:45 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-06 14:47:45 -0400
commita8316252db95e3d77f9f0e9beb89cfcb4573d5b1 (patch)
treee5905bce9611e35ccb2f84481232fca0e657ff42 /examples/log/log.tm
parenta0ac652cd1eebdc42425b34f1685f8cb20cb4eea (diff)
parent73246764f88f6f652316ee0c138a990d836698a7 (diff)
Merge branch 'main' into simplified-quotes
Diffstat (limited to 'examples/log/log.tm')
-rw-r--r--examples/log/log.tm50
1 files changed, 0 insertions, 50 deletions
diff --git a/examples/log/log.tm b/examples/log/log.tm
deleted file mode 100644
index 2798b7ae..00000000
--- a/examples/log/log.tm
+++ /dev/null
@@ -1,50 +0,0 @@
-use <time.h>
-use <stdio.h>
-
-timestamp_format := CString("%F %T")
-
-logfiles : @|Path|
-
-func _timestamp(->Text)
- c_str := C_code:CString`
- char *str = GC_MALLOC_ATOMIC(20);
- time_t t; time(&t);
- struct tm *tm_info = localtime(&t);
- strftime(str, 20, "%F %T", tm_info);
- str
- `
- return c_str.as_text()
-
-func info(text:Text, newline=yes)
- say("\[2]⚫ $text\[]", newline)
- for file in logfiles
- file.append("$(_timestamp()) [info] $text\n")
-
-func debug(text:Text, newline=yes)
- say("\[32]🟢 $text\[]", newline)
- for file in logfiles
- file.append("$(_timestamp()) [debug] $text\n")
-
-func warn(text:Text, newline=yes)
- say("\[33;1]🟡 $text\[]", newline)
- for file in logfiles
- file.append("$(_timestamp()) [warn] $text\n")
-
-func error(text:Text, newline=yes)
- say("\[31;1]🔴 $text\[]", newline)
- for file in logfiles
- file.append("$(_timestamp()) [error] $text\n")
-
-func add_logfile(file:Path)
- logfiles.add(file)
-
-func remove_logfile(file:Path)
- logfiles.remove(file)
-
-func main()
- add_logfile((./log.txt))
- >> info("Hello")
- >> debug("Hello")
- >> warn("Hello")
- >> error("Hello")
-