add bannner

This commit is contained in:
kingecg 2023-11-28 23:26:58 +08:00
parent 10c818e063
commit c67da73f30
4 changed files with 68 additions and 7 deletions

7
.vscode/launch.json vendored
View File

@ -9,7 +9,12 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
"program": "${fileDirname}",
"args": [
"--config",
"config.json",
"version"
]
},
{
"name": "Launch file",

View File

@ -4,15 +4,34 @@ import (
"fmt"
"os"
"git.pyer.club/kingecg/gologger"
"git.pyer.club/kingecg/gosocketio/config"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "gosocketio",
Short: "A golang socket.io server",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("gossocketio called")
},
var (
configFile string
rootCmd = &cobra.Command{
Use: "gosocketio",
Short: "A golang socket.io server",
Run: func(cmd *cobra.Command, args []string) {
},
}
)
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVarP(&configFile, "config", "c", "", "config file")
}
func initConfig() {
if configFile != "" {
config.LoadConfig(configFile)
}
gologger.Configure(config.GetConfig().Logging)
logger := gologger.GetLogger("main")
logger.Debug("On init")
}
// run app cmd

23
config.json Normal file
View File

@ -0,0 +1,23 @@
{
"host": "localhost",
"port": 3306,
"logging": {
"appenders": {
"out": {
"type": "console"
},
"server": {
"type": "file",
"options":{
"file": "./logs/server.log"
}
}
},
"categories": {
"default": {
"appenders": ["out","server"],
"level": "debug"
}
}
}
}

14
main.go
View File

@ -1,9 +1,23 @@
package main
import (
"fmt"
"git.pyer.club/kingecg/gosocketio/cli"
)
const title string = `
___ __ _ _____ __
/ _ \___ / _\ ___ ___| | _____ \_ \___ / _\ ___ _ ____ _____ _ __
/ /_\/ _ \ \ \ / _ \ / __| |/ / _ \ / /\/ _ \ \ \ / _ \ '__\ \ / / _ \ '__|
/ /_\\ (_) | _\ \ (_) | (__| < __/\/ /_| (_) | _\ \ __/ | \ V / __/ |
\____/\___/ \__/\___/ \___|_|\_\___\____/ \___/ \__/\___|_| \_/ \___|_|
`
func main() {
fmt.Print(title)
cli.Execute()
}