Remove fmt.Prinln and add Zerolog logging system
All checks were successful
Build and Push Docker Image / build_and_push (push) Successful in 1m51s
All checks were successful
Build and Push Docker Image / build_and_push (push) Successful in 1m51s
This commit is contained in:
19
main.go
19
main.go
@@ -1,7 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"git.coopgo.io/coopgo-platform/agenda/grpcapi"
|
||||
"git.coopgo.io/coopgo-platform/agenda/handlers"
|
||||
@@ -9,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||
|
||||
cfg, err := ReadConfig()
|
||||
if err != nil {
|
||||
@@ -21,6 +25,10 @@ func main() {
|
||||
dev_env = cfg.GetBool("dev_env")
|
||||
)
|
||||
|
||||
if dev_env {
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
}
|
||||
|
||||
storage, err := storage.NewStorage(cfg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -28,13 +36,10 @@ func main() {
|
||||
|
||||
handler := handlers.NewHandler(cfg, storage)
|
||||
|
||||
fmt.Println("Running", service_name, ":")
|
||||
if dev_env {
|
||||
fmt.Printf("\033]0;%s\007", service_name)
|
||||
}
|
||||
|
||||
failed := make(chan error)
|
||||
|
||||
log.Info().Str("service_name", service_name).Msg("Running service")
|
||||
|
||||
if grpc_enable {
|
||||
go grpcapi.Run(failed, cfg, handler)
|
||||
}
|
||||
@@ -43,5 +48,5 @@ func main() {
|
||||
|
||||
err = <-failed
|
||||
|
||||
fmt.Println("Terminating :", err)
|
||||
log.Fatal().Err(err).Msg("Terminating server")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user