Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
ybkuroki committed Nov 15, 2020
1 parent 54903b7 commit 676e853
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"flag"
"fmt"
"os"

"github.com/jinzhu/configor"
)
Expand Down Expand Up @@ -57,7 +58,8 @@ func Load() {
flag.Parse()
config = &Config{}
if err := configor.Load(config, "application."+*env+".yml"); err != nil {
fmt.Println(err)
fmt.Printf("Failed to read application.%s.yml: %s", *env, err)
os.Exit(2)
}
}

Expand Down
8 changes: 6 additions & 2 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package logger
import (
"fmt"
"io/ioutil"
"os"

"github.com/ybkuroki/go-webapp-sample/config"
"go.uber.org/zap"
Expand Down Expand Up @@ -47,15 +48,18 @@ func NewLogger(zap *zap.SugaredLogger) *Logger {
func InitLogger() {
configYaml, err := ioutil.ReadFile("./zaplogger." + *config.GetEnv() + ".yml")
if err != nil {
fmt.Printf("Failed to read zap logger configuration: %s", err)
fmt.Printf("Failed to read logger configuration: %s", err)
os.Exit(2)
}
var myConfig *Config
if err := yaml.Unmarshal(configYaml, &myConfig); err != nil {
fmt.Printf("Failed to read zap logger configuration: %s", err)
os.Exit(2)
}
zap, err := build(myConfig)
if err != nil {
fmt.Printf("Error")
fmt.Printf("Failed to compose zap logger : %s", err)
os.Exit(2)
}
sugar := zap.Sugar()
// set package varriable logger.
Expand Down

0 comments on commit 676e853

Please sign in to comment.