aboutsummaryrefslogtreecommitdiff
path: root/examples/log.tm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/log.tm')
-rw-r--r--examples/log.tm13
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/log.tm b/examples/log.tm
index 765fc61f..24397c90 100644
--- a/examples/log.tm
+++ b/examples/log.tm
@@ -6,17 +6,16 @@ timestamp_format := CString("%F %T")
logfiles := {:Path}
func _timestamp()->Text:
- return inline C (
+ c_str := inline C (
({
char *str = GC_MALLOC_ATOMIC(20);
- time_t t;
- time(&t);
- struct tm *tm_info;
- tm_info = localtime(&t);
+ time_t t; time(&t);
+ struct tm *tm_info = localtime(&t);
strftime(str, 20, "%F %T", tm_info);
- Text$format("%s", str);
+ str;
})
- ) : Text
+ ) : CString
+ return c_str:as_text()
func info(text:Text, newline=yes):
say("$\[2]⚫ $text$\[]", newline)