AFAIRE
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.
logger/format.go

43 lines
996 B

/*
------------------------------------------------------------------------------------------------------------------------
####### logger ####### Copyright (c) 2021 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
}
/*
######################################################################################################## @(°_°)@ #######
*/