mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: add logo printing functionality and update logger usage
- Introduced a new utility function to print a logo and welcome information for the Crawlab server, enhancing user experience during startup. - Updated logger variable names in the apps package for consistency and clarity. - Added a new dependency on github.com/common-nighthawk/go-figure to facilitate logo rendering. - Improved the server command to display the logo when the server starts, provided the user is not using the pro version.
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
)
|
||||
|
||||
var utilsLogger = utils.NewLogger("AppsUtils")
|
||||
var logger = utils.NewLogger("Apps")
|
||||
|
||||
func Start(app App) {
|
||||
start(app)
|
||||
@@ -19,9 +19,9 @@ func start(app App) {
|
||||
|
||||
func initModule(name string, fn func() error) (err error) {
|
||||
if err := fn(); err != nil {
|
||||
utilsLogger.Errorf("init %s error: %v", name, err)
|
||||
logger.Errorf("init %s error: %v", name, err)
|
||||
panic(err)
|
||||
}
|
||||
utilsLogger.Infof("initialized %s successfully", name)
|
||||
logger.Infof("initialized %s successfully", name)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/apps"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -15,6 +16,11 @@ var serverCmd = &cobra.Command{
|
||||
Short: "Start Crawlab server",
|
||||
Long: `Start Crawlab node server that can serve as API, task scheduler, task runner, etc.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// print logo if not pro
|
||||
if !utils.IsPro() {
|
||||
utils.PrintLogoWithWelcomeInfo()
|
||||
}
|
||||
|
||||
// app
|
||||
svr := apps.GetServer()
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ require (
|
||||
github.com/cloudflare/circl v1.3.7 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/emirpasic/gods v1.18.1 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
|
||||
@@ -129,6 +129,8 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
|
||||
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ=
|
||||
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
|
||||
26
core/utils/logo.go
Normal file
26
core/utils/logo.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/common-nighthawk/go-figure"
|
||||
)
|
||||
|
||||
func PrintLogoWithWelcomeInfo() {
|
||||
printLogo()
|
||||
printWelcomeInfo()
|
||||
}
|
||||
|
||||
func printLogo() {
|
||||
figure.NewColorFigure("Crawlab", "slant", "blue", true).Print()
|
||||
}
|
||||
|
||||
func printWelcomeInfo() {
|
||||
fmt.Println("Distributed web crawling platform for efficient, scalable data extraction.")
|
||||
fmt.Println("For more information, please refer to the following resources:")
|
||||
fmt.Println("- Website: https://crawlab.cn")
|
||||
fmt.Println("- Documentation: https://docs.crawlab.cn")
|
||||
fmt.Println("- GitHub: https://github.com/crawlab-team/crawlab")
|
||||
if IsMaster() {
|
||||
fmt.Println("Visit https://localhost:8080 for the web ui, once the server is ready.")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user