You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
996 B
42 lines
996 B
/* |
|
------------------------------------------------------------------------------------------------------------------------ |
|
####### logger ####### Copyright (c) 2021-2022 losyme ############################################## MIT License ####### |
|
------------------------------------------------------------------------------------------------------------------------ |
|
*/ |
|
|
|
package logger |
|
|
|
import ( |
|
"strings" |
|
|
|
"forge.chapril.org/losyme/buffer" |
|
) |
|
|
|
const ( |
|
_maxIDLen = 8 |
|
_maxNameLen = 10 |
|
) |
|
|
|
const _bufSize = 256 |
|
|
|
var BufPool = buffer.NewPool(_bufSize) |
|
|
|
func loggerLabel(id, name string) string { |
|
if len(name) > _maxNameLen { |
|
name = name[:_maxNameLen] |
|
} else { |
|
name = strings.Repeat(".", _maxNameLen-len(name)) + name |
|
} |
|
|
|
if len(id) > _maxIDLen { |
|
id = id[:_maxIDLen] |
|
} else { |
|
id = strings.Repeat(".", _maxIDLen-len(id)) + id |
|
} |
|
|
|
return name + ":" + id |
|
} |
|
|
|
/* |
|
######################################################################################################## @(°_°)@ ####### |
|
*/
|
|
|