mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Move log timestamping out to do_time_header proc
This commit is contained in:
@@ -73,15 +73,7 @@ file_console_logger_proc :: proc(logger_data: rawptr, level: Level, text: string
|
|||||||
do_level_header(options, level, &buf)
|
do_level_header(options, level, &buf)
|
||||||
|
|
||||||
when time.IS_SUPPORTED {
|
when time.IS_SUPPORTED {
|
||||||
if Full_Timestamp_Opts & options != nil {
|
do_time_header(options, &buf, time.now())
|
||||||
fmt.sbprint(&buf, "[")
|
|
||||||
t := time.now()
|
|
||||||
y, m, d := time.date(t)
|
|
||||||
h, min, s := time.clock(t)
|
|
||||||
if .Date in options { fmt.sbprintf(&buf, "%d-%02d-%02d ", y, m, d) }
|
|
||||||
if .Time in options { fmt.sbprintf(&buf, "%02d:%02d:%02d", h, min, s) }
|
|
||||||
fmt.sbprint(&buf, "] ")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_location_header(options, &buf, location)
|
do_location_header(options, &buf, location)
|
||||||
@@ -125,6 +117,19 @@ do_level_header :: proc(opts: Options, level: Level, str: ^strings.Builder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_time_header :: proc(opts: Options, buf: ^strings.Builder, t: time.Time) {
|
||||||
|
when time.IS_SUPPORTED {
|
||||||
|
if Full_Timestamp_Opts & opts != nil {
|
||||||
|
fmt.sbprint(buf, "[")
|
||||||
|
y, m, d := time.date(t)
|
||||||
|
h, min, s := time.clock(t)
|
||||||
|
if .Date in opts { fmt.sbprintf(buf, "%d-%02d-%02d ", y, m, d) }
|
||||||
|
if .Time in opts { fmt.sbprintf(buf, "%02d:%02d:%02d", h, min, s) }
|
||||||
|
fmt.sbprint(buf, "] ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do_location_header :: proc(opts: Options, buf: ^strings.Builder, location := #caller_location) {
|
do_location_header :: proc(opts: Options, buf: ^strings.Builder, location := #caller_location) {
|
||||||
if Location_Header_Opts & opts == nil {
|
if Location_Header_Opts & opts == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user