From 77457f9001cee206ff75cf3ca78bda142193fd94 Mon Sep 17 00:00:00 2001 From: Martin Hotmann Date: Sat, 10 Feb 2024 19:55:02 +0100 Subject: [PATCH 1/7] Update listen.go (unform INFO prints at startip + cosmetics) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BEFORE: ``` _______ __ / ____(_) /_ ___ _____ / /_ / / __ \/ _ \/ ___/ / __/ / / /_/ / __/ / /_/ /_/_.___/\___/_/ v3.0.0-beta.1 -------------------------------------------------- INFO Server started on http://127.0.0.1:8003 (bound on host 0.0.0.0 and port 8003) INFO Application name: TEST APP INFO Total handlers count: 5 INFO Prefork: Disabled INFO PID: 2342 INFO Total process count: 1 20:49:50 | 200 | 593.769µs | 123.123.123.123 | GET | / ``` AFTER: ``` _______ __ / ____(_) /_ ___ _____ / /_ / / __ \/ _ \/ ___/ / __/ / / /_/ / __/ / /_/ /_/_.___/\___/_/ v3.0.0-beta.1 -------------------------------------------------- INFO Server started on: http://127.0.0.1:8003 (bound on host 0.0.0.0 and port 8003) INFO Application name: TEST APP INFO Total handlers count: 5 INFO Prefork: Disabled INFO PID: 2342 INFO Total process count: 1 20:49:50 | 200 | 593.769µs | 123.123.123.123 | GET | / ``` --- listen.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/listen.go b/listen.go index f27d7217366..f18d38b9d02 100644 --- a/listen.go +++ b/listen.go @@ -354,27 +354,27 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC if host == "0.0.0.0" { _, _ = fmt.Fprintf(out, - "%sINFO%s Server started on %s%s://127.0.0.1:%s%s (bound on host 0.0.0.0 and port %s)\n", + "%sINFO%s Server started on: \t%s%s://127.0.0.1:%s%s (bound on host 0.0.0.0 and port %s)\n", colors.Green, colors.Reset, colors.Blue, scheme, port, colors.Reset, port) } else { _, _ = fmt.Fprintf(out, - "%sINFO%s Server started on %s%s%s\n", + "%sINFO%s Server started on: \t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, fmt.Sprintf("%s://%s:%s", scheme, host, port), colors.Reset) } if app.config.AppName != "" { - _, _ = fmt.Fprintf(out, "%sINFO%s Application name: %s%s%s\n", colors.Green, colors.Reset, colors.Blue, app.config.AppName, colors.Reset) + _, _ = fmt.Fprintf(out, "%sINFO%s Application name: \t\t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, app.config.AppName, colors.Reset) } _, _ = fmt.Fprintf(out, - "%sINFO%s Total handlers count: %s%s%s\n", + "%sINFO%s Total handlers count: \t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, strconv.Itoa(int(app.handlersCount)), colors.Reset) if isPrefork == "Enabled" { - _, _ = fmt.Fprintf(out, "%sINFO%s Prefork: %s%s%s\n", colors.Green, colors.Reset, colors.Blue, isPrefork, colors.Reset) + _, _ = fmt.Fprintf(out, "%sINFO%s Prefork: \t\t\t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, isPrefork, colors.Reset) } else { - _, _ = fmt.Fprintf(out, "%sINFO%s Prefork: %s%s%s\n", colors.Green, colors.Reset, colors.Red, isPrefork, colors.Reset) + _, _ = fmt.Fprintf(out, "%sINFO%s Prefork: \t\t\t%s%s%s\n", colors.Green, colors.Reset, colors.Red, isPrefork, colors.Reset) } - _, _ = fmt.Fprintf(out, "%sINFO%s PID: %s%v%s\n", colors.Green, colors.Reset, colors.Blue, os.Getpid(), colors.Reset) - _, _ = fmt.Fprintf(out, "%sINFO%s Total process count: %s%s%s\n", colors.Green, colors.Reset, colors.Blue, procs, colors.Reset) + _, _ = fmt.Fprintf(out, "%sINFO%s PID: \t\t\t%s%v%s\n", colors.Green, colors.Reset, colors.Blue, os.Getpid(), colors.Reset) + _, _ = fmt.Fprintf(out, "%sINFO%s Total process count: \t%s%s%s\n", colors.Green, colors.Reset, colors.Blue, procs, colors.Reset) if cfg.EnablePrefork { // Turn the `pids` variable (in the form ",a,b,c,d,e,f,etc") into a slice of PIDs @@ -385,7 +385,7 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC } } - _, _ = fmt.Fprintf(out, "%sINFO%s Child PIDs: %s", colors.Green, colors.Reset, colors.Blue) + _, _ = fmt.Fprintf(out, "%sINFO%s Child PIDs: \t\t%s", colors.Green, colors.Reset, colors.Blue) totalPids := len(pidSlice) rowTotalPidCount := 10 for i := 0; i < totalPids; i += rowTotalPidCount { @@ -405,6 +405,9 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC } } +// add new Line as spacer +_, _ = fmt.Fprintf(out, "\n%s", colors.Reset) + // printRoutesMessage print all routes with method, path, name and handlers // in a format of table, like this: // method | path | name | handlers From 004bd9c33888a277d26cde4dafb6986479f86902 Mon Sep 17 00:00:00 2001 From: Martin Hotmann Date: Sat, 10 Feb 2024 19:59:32 +0100 Subject: [PATCH 2/7] fix spacer --- listen.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/listen.go b/listen.go index f18d38b9d02..be8f88be099 100644 --- a/listen.go +++ b/listen.go @@ -403,10 +403,11 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC _, _ = fmt.Fprintf(out, "\n%s", colors.Reset) } } -} -// add new Line as spacer -_, _ = fmt.Fprintf(out, "\n%s", colors.Reset) + // add new Line as spacer + _, _ = fmt.Fprintf(out, "\n%s", colors.Reset) + +} // printRoutesMessage print all routes with method, path, name and handlers // in a format of table, like this: From f6fd827a53f54bd0cb91dad53240a9ad601222e4 Mon Sep 17 00:00:00 2001 From: Martin Hotmann Date: Sat, 10 Feb 2024 20:00:39 +0100 Subject: [PATCH 3/7] fix indentation for fiber version --- listen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listen.go b/listen.go index be8f88be099..9473fafe9d4 100644 --- a/listen.go +++ b/listen.go @@ -30,7 +30,7 @@ var figletFiberText = ` / ____(_) /_ ___ _____ / /_ / / __ \/ _ \/ ___/ / __/ / / /_/ / __/ / -/_/ /_/_.___/\___/_/ %s` +/_/ /_/_.___/\___/_/ %s` const ( globalIpv4Addr = "0.0.0.0" From 2d15a85c1f7effb31362d2231dc00a0ce185d0d4 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 10 Feb 2024 20:59:13 +0100 Subject: [PATCH 4/7] fix linting --- listen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listen.go b/listen.go index 9473fafe9d4..ad8527bd17d 100644 --- a/listen.go +++ b/listen.go @@ -406,7 +406,7 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC // add new Line as spacer _, _ = fmt.Fprintf(out, "\n%s", colors.Reset) - + } // printRoutesMessage print all routes with method, path, name and handlers From fb47f71082cae090d0ea611444a9eaaa6d3c0984 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 10 Feb 2024 21:17:22 +0100 Subject: [PATCH 5/7] fix linting #2 --- listen.go | 1 - 1 file changed, 1 deletion(-) diff --git a/listen.go b/listen.go index ad8527bd17d..e293a1ef7c2 100644 --- a/listen.go +++ b/listen.go @@ -406,7 +406,6 @@ func (app *App) startupMessage(addr string, isTLS bool, pids string, cfg ListenC // add new Line as spacer _, _ = fmt.Fprintf(out, "\n%s", colors.Reset) - } // printRoutesMessage print all routes with method, path, name and handlers From a3b7be3d374a1538537a1729710219a476918b09 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 10 Feb 2024 21:36:38 +0100 Subject: [PATCH 6/7] fix listen_test.go to match newly expected output. --- listen_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listen_test.go b/listen_test.go index 9134e357a20..2af3cc23a66 100644 --- a/listen_test.go +++ b/listen_test.go @@ -355,7 +355,7 @@ func Test_Listen_Master_Process_Show_Startup_Message(t *testing.T) { require.Contains(t, startupMessage, "(bound on host 0.0.0.0 and port 3000)") require.Contains(t, startupMessage, "Child PIDs") require.Contains(t, startupMessage, "11111, 22222, 33333, 44444, 55555, 60000") - require.Contains(t, startupMessage, fmt.Sprintf("Prefork: %sEnabled%s", colors.Blue, colors.Reset)) + require.Contains(t, startupMessage, fmt.Sprintf("Prefork: \t\t\t%sEnabled%s", colors.Blue, colors.Reset)) } // go test -run Test_Listen_Master_Process_Show_Startup_MessageWithAppName From e0ce19af0d0c8537d82d9a07c40fce175059d4ef Mon Sep 17 00:00:00 2001 From: the-hotmann Date: Sat, 10 Feb 2024 21:39:06 +0100 Subject: [PATCH 7/7] fix test again --- listen_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listen_test.go b/listen_test.go index 2af3cc23a66..ffd53794024 100644 --- a/listen_test.go +++ b/listen_test.go @@ -402,7 +402,7 @@ func Test_Listen_Master_Process_Show_Startup_MessageWithDisabledPreforkAndCustom require.Contains(t, startupMessage, fmt.Sprintf("%sINFO%s", colors.Green, colors.Reset)) require.Contains(t, startupMessage, fmt.Sprintf("%s%s%s", colors.Blue, appName, colors.Reset)) require.Contains(t, startupMessage, fmt.Sprintf("%s%s%s", colors.Blue, "https://server.com:8081", colors.Reset)) - require.Contains(t, startupMessage, fmt.Sprintf("Prefork: %sDisabled%s", colors.Red, colors.Reset)) + require.Contains(t, startupMessage, fmt.Sprintf("Prefork: \t\t\t%sDisabled%s", colors.Red, colors.Reset)) } // go test -run Test_Listen_Print_Route