mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
log: use @[noinline]
for level_from_tag/1 and target_from_label/1 to avoid triggering panics for programs using log
, compiled with -prod and -cc gcc>10 (fix #24874)
This commit is contained in:
parent
ee6eed3c22
commit
55b1236421
@ -20,6 +20,7 @@ pub enum LogTarget {
|
||||
}
|
||||
|
||||
// tag_to_console returns the tag for log level `l` as a colored string.
|
||||
@[noinline]
|
||||
fn tag_to_console(l Level, short_tag bool) string {
|
||||
if short_tag {
|
||||
return match l {
|
||||
@ -43,6 +44,7 @@ fn tag_to_console(l Level, short_tag bool) string {
|
||||
}
|
||||
|
||||
// tag_to_file returns the tag for log level `l` as a string.
|
||||
@[noinline]
|
||||
fn tag_to_file(l Level, short_tag bool) string {
|
||||
if short_tag {
|
||||
return match l {
|
||||
@ -67,6 +69,7 @@ fn tag_to_file(l Level, short_tag bool) string {
|
||||
|
||||
// level_from_tag returns the log level from the given string.
|
||||
// It returns `none` when it does not find a match.
|
||||
@[noinline]
|
||||
pub fn level_from_tag(tag string) ?Level {
|
||||
return match tag {
|
||||
'DISABLED', ' ' { Level.disabled }
|
||||
@ -81,6 +84,7 @@ pub fn level_from_tag(tag string) ?Level {
|
||||
|
||||
// target_from_label returns the log target from the given string.
|
||||
// It returns `none` when it does not find a match.
|
||||
@[noinline]
|
||||
pub fn target_from_label(label string) ?LogTarget {
|
||||
return match label {
|
||||
'console' { LogTarget.console }
|
||||
|
Loading…
x
Reference in New Issue
Block a user