diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2020-07-22 22:27:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-22 22:27:53 +0100 |
| commit | b04bc21ec679140b156eba28c263d17c34fd7232 (patch) | |
| tree | 058f8bb321123a56cedfe95a3826eff7264b7a9e | |
| parent | 2945feecde92015d19be89f685bfe489345a544b (diff) | |
| parent | 36cac87387552ef0761d22333afc884dadcc4386 (diff) | |
Merge pull request #704 from oskarnp/log_thread_id
Add .Thread_Id option to log package
| -rw-r--r-- | core/log/file_console_logger.odin | 6 | ||||
| -rw-r--r-- | core/runtime/core.odin | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/core/log/file_console_logger.odin b/core/log/file_console_logger.odin index ccecbc8b8..757bb5ff5 100644 --- a/core/log/file_console_logger.odin +++ b/core/log/file_console_logger.odin @@ -83,6 +83,12 @@ file_console_logger_proc :: proc(logger_data: rawptr, level: Level, text: string do_location_header(options, &buf, location); + if .Thread_Id in options { + // NOTE(Oskar): not using context.thread_id here since that could be + // incorrect when replacing context for a thread. + fmt.sbprintf(&buf, "[{}] ", os.current_thread_id()); + } + if data.ident != "" do fmt.sbprintf(&buf, "[%s] ", data.ident); //TODO(Hoej): When we have better atomics and such, make this thread-safe fmt.fprintf(h, "%s %s\n", strings.to_string(buf), text); diff --git a/core/runtime/core.odin b/core/runtime/core.odin index 7d1a7bdd5..1ed16d127 100644 --- a/core/runtime/core.odin +++ b/core/runtime/core.odin @@ -279,7 +279,8 @@ Logger_Option :: enum { Long_File_Path, Line, Procedure, - Terminal_Color + Terminal_Color, + Thread_Id } Logger_Options :: bit_set[Logger_Option]; |