orca: implement core:time and core:log

This commit is contained in:
Laytan Laats
2024-08-23 18:25:10 +02:00
parent 574dc5efe6
commit caef37bc18
5 changed files with 53 additions and 41 deletions
+22
View File
@@ -0,0 +1,22 @@
// File contains Odin specific helpers.
package orca
import "base:runtime"
create_odin_logger :: proc(lowest := runtime.Logger_Level.Debug, ident := "") -> runtime.Logger {
return runtime.Logger{odin_logger_proc, nil, lowest, {}}
}
odin_logger_proc :: proc(logger_data: rawptr, level: runtime.Logger_Level, text: string, options: runtime.Logger_Options, location := #caller_location) {
cbuf := make([]byte, len(text)+1, context.temp_allocator)
copy(cbuf, text)
ctext := cstring(raw_data(cbuf))
switch level {
case .Debug, .Info: log_info(ctext, location)
case .Warning: log_warning(ctext, location)
case: fallthrough
case .Error, .Fatal: log_error(ctext, location)
}
}