mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
log/net: switch => match
This commit is contained in:
parent
7ba5248e56
commit
ed55826686
2 changed files with 123 additions and 111 deletions
|
@ -50,56 +50,56 @@ pub fn (l Log) fatal(s string){
|
|||
|
||||
pub fn (l Log) error(s string){
|
||||
if l.level >= ERROR{
|
||||
switch l.output {
|
||||
case 'terminal':
|
||||
f := term.red('E')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
|
||||
default:
|
||||
l.log_file(s, 'E')
|
||||
match l.output {
|
||||
'terminal'{
|
||||
f := term.red('E')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
} else {
|
||||
l.log_file(s, 'E')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (l Log) warn(s string){
|
||||
if l.level >= WARN{
|
||||
switch l.output {
|
||||
case 'terminal':
|
||||
f := term.yellow('W')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
|
||||
default:
|
||||
l.log_file(s, 'W')
|
||||
match l.output {
|
||||
'terminal'{
|
||||
f := term.yellow('W')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
} else {
|
||||
l.log_file(s, 'W')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (l Log) info(s string){
|
||||
if l.level >= INFO{
|
||||
switch l.output {
|
||||
case 'terminal':
|
||||
f := term.white('I')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
|
||||
default:
|
||||
l.log_file(s, 'I')
|
||||
match l.output {
|
||||
'terminal'{
|
||||
f := term.white('I')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
} else {
|
||||
l.log_file(s, 'I')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (l Log) debug(s string){
|
||||
if l.level >= DEBUG{
|
||||
switch l.output {
|
||||
case 'terminal':
|
||||
f := term.blue('D')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
|
||||
default:
|
||||
l.log_file(s, 'D')
|
||||
match l.output {
|
||||
'terminal' {
|
||||
f := term.blue('D')
|
||||
t := time.now()
|
||||
println('[$f ${t.format_ss()}] $s')
|
||||
} else {
|
||||
l.log_file(s, 'D')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue