-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.odin
More file actions
33 lines (29 loc) · 907 Bytes
/
logger.odin
File metadata and controls
33 lines (29 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package extra
//A Logger that maps from raylib's TraceLog to odin's "core:log"
import "core:log"
import "core:strings"
import rl "vendor:raylib"
//Creates a logger that uses raylib's TraceLog function, you can use "core:log" normally and it will output there
CreateRaylibLogger :: proc() -> log.Logger {
rl.SetTraceLogLevel(.ALL)
return {data = nil, lowest_level = .Debug, options = {}, procedure = raylib_logger_proc}
}
//Internal proc that uses TraceLog to write logs
@(private)
raylib_logger_proc :: proc(
logger_data: rawptr,
level: log.Level,
text: string,
options: log.Options,
location := #caller_location,
) {
@(static, rodata)
odinLevelToRayLibLevel := #sparse[log.Level]rl.TraceLogLevel {
.Debug = .DEBUG,
.Info = .INFO,
.Warning = .WARNING,
.Error = .ERROR,
.Fatal = .FATAL,
}
rl.TraceLog(odinLevelToRayLibLevel[level], "%.*s", i32(len(text)), raw_data(text))
}