mirror of https://github.com/gofiber/fiber.git
🎨 Add black colors to default overriding function (#1993)
* Fix padding around app name in startup message when it contains non-ascii characters * fix conflict, allow ending space only for odd length strings * move startup message tests to listen_test.go * add black color to defaultColors overriding function, fix (again) padding in startupMessagepull/1994/head
parent
1cca495c7b
commit
4f7816774b
4
color.go
4
color.go
|
@ -67,6 +67,10 @@ var DefaultColors = Colors{
|
|||
|
||||
// defaultColors is a function to override default colors to config
|
||||
func defaultColors(colors Colors) Colors {
|
||||
if colors.Black == "" {
|
||||
colors.Black = DefaultColors.Black
|
||||
}
|
||||
|
||||
if colors.Red == "" {
|
||||
colors.Red = DefaultColors.Red
|
||||
}
|
||||
|
|
|
@ -212,8 +212,8 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
|
|||
str := fmt.Sprintf("%"+pad+"s", " ")
|
||||
str += fmt.Sprintf("%s%s%s", colors.Cyan, s, colors.Black)
|
||||
str += fmt.Sprintf("%"+pad+"s", " ")
|
||||
if len([]rune(str))-10 < width && len([]rune(str))%2 != 0 {
|
||||
// add an ending space if the length of str is odd and str is not too long
|
||||
if len([]rune(s))-10 < width && len([]rune(s))%2 == 0 {
|
||||
// add an ending space if the length of str is even and str is not too long
|
||||
str += " "
|
||||
}
|
||||
return str
|
||||
|
@ -256,7 +256,7 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
|
|||
if app.config.AppName != "" {
|
||||
mainLogo += " │ " + centerValue(app.config.AppName, 49) + " │\n"
|
||||
}
|
||||
mainLogo += " │ " + centerValue(" Fiber v"+Version, 49) + " │\n"
|
||||
mainLogo += " │ " + centerValue("Fiber v"+Version, 49) + " │\n"
|
||||
|
||||
if host == "0.0.0.0" {
|
||||
mainLogo +=
|
||||
|
|
Loading…
Reference in New Issue