diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-17 02:09:52 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-23 18:25:10 +0200 |
| commit | caef37bc18477b1bb945f28be2598dd5fabe2473 (patch) | |
| tree | d0978f987b01f47bc74d6472edfd1de6fc5d9943 /core/sys/orca | |
| parent | 574dc5efe6a9397217a810f5918bacc0346f469f (diff) | |
orca: implement core:time and core:log
Diffstat (limited to 'core/sys/orca')
| -rw-r--r-- | core/sys/orca/macros.odin | 41 | ||||
| -rw-r--r-- | core/sys/orca/odin.odin | 22 |
2 files changed, 22 insertions, 41 deletions
diff --git a/core/sys/orca/macros.odin b/core/sys/orca/macros.odin index 9e7dbed85..d6a1a0f82 100644 --- a/core/sys/orca/macros.odin +++ b/core/sys/orca/macros.odin @@ -2,8 +2,6 @@ package orca -import "core:fmt" - //////////////////////////////////////////////////////////////////////////////// // Helpers for logging, asserting and aborting. //////////////////////////////////////////////////////////////////////////////// @@ -18,16 +16,6 @@ log_error :: proc "contextless" (msg: cstring, loc := #caller_location) { ) } -log_errorf :: proc(format: string, args: ..any, loc := #caller_location) { - log_ext( - .ERROR, - cstring(raw_data(loc.procedure)), - cstring(raw_data(loc.file_path)), - loc.line, - fmt.ctprintf(format, ..args), - ) -} - log_warning :: proc "contextless" (msg: cstring, loc := #caller_location) { log_ext( .WARNING, @@ -38,16 +26,6 @@ log_warning :: proc "contextless" (msg: cstring, loc := #caller_location) { ) } -log_warningf :: proc(format: string, args: ..any, loc := #caller_location) { - log_ext( - .WARNING, - cstring(raw_data(loc.procedure)), - cstring(raw_data(loc.file_path)), - loc.line, - fmt.ctprintf(format, ..args), - ) -} - log_info :: proc "contextless" (msg: cstring, loc := #caller_location) { log_ext( .INFO, @@ -58,16 +36,6 @@ log_info :: proc "contextless" (msg: cstring, loc := #caller_location) { ) } -log_infof :: proc(format: string, args: ..any, loc := #caller_location) { - log_ext( - .INFO, - cstring(raw_data(loc.procedure)), - cstring(raw_data(loc.file_path)), - loc.line, - fmt.ctprintf(format, ..args), - ) -} - abort :: proc "contextless" (msg: cstring, loc := #caller_location) { abort_ext( cstring(raw_data(loc.procedure)), @@ -77,15 +45,6 @@ abort :: proc "contextless" (msg: cstring, loc := #caller_location) { ) } -abortf :: proc(format: string, args: ..any, loc := #caller_location) { - abort_ext( - cstring(raw_data(loc.procedure)), - cstring(raw_data(loc.file_path)), - loc.line, - fmt.ctprintf(format, ..args), - ) -} - //////////////////////////////////////////////////////////////////////////////// // Types and helpers for doubly-linked lists. //////////////////////////////////////////////////////////////////////////////// diff --git a/core/sys/orca/odin.odin b/core/sys/orca/odin.odin new file mode 100644 index 000000000..5c3e3e4d9 --- /dev/null +++ b/core/sys/orca/odin.odin @@ -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) + } +} |