From 25bb9aca92f9ddeb9e743ff988b678b3805e8b19 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 21 Mar 2018 20:42:06 +0900 Subject: [PATCH] ing --- constants.go | 1 - external/grpc/pool.go | 4 +--- main.go | 18 +++++++++++++----- module/member/reset_password.go | 6 +++--- module/member/signin.go | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/constants.go b/constants.go index 0ab0193..e7be11e 100644 --- a/constants.go +++ b/constants.go @@ -1,7 +1,6 @@ package main const ( - ConfigPathFlagName = "config-dir" ConfigFileName = "config.json" GRPCUserIDKey = "GRPCUserID" diff --git a/external/grpc/pool.go b/external/grpc/pool.go index cbc7a0b..c273076 100644 --- a/external/grpc/pool.go +++ b/external/grpc/pool.go @@ -1,8 +1,6 @@ package grpc import ( - "fmt" - "google.golang.org/grpc" cgp "git.loafle.net/commons_go/grpc_pool" @@ -23,7 +21,7 @@ func ExternalInit() { grpcPool = cgp.New(ph) if err := grpcPool.Start(); nil != err { - logging.Logger().Panic(fmt.Sprintf("App: %v", err)) + logging.Logger().Panicf("App: %v", err) return } } diff --git a/main.go b/main.go index 584d8f9..7664f78 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( cc "git.loafle.net/commons_go/config" "git.loafle.net/commons_go/cors_fasthttp" "git.loafle.net/commons_go/logging" + oocc "git.loafle.net/overflow/overflow_commons_go/config" "git.loafle.net/overflow/overflow_server_app/config" "git.loafle.net/overflow/overflow_server_app/external" "git.loafle.net/overflow/overflow_server_app/module/member" @@ -14,14 +15,21 @@ import ( "github.com/valyala/fasthttp" ) -func init() { - configPath := flag.String(ConfigPathFlagName, "./", "The path of config file") +var ( + configDir *string + logConfigPath *string +) +func init() { + configDir = oocc.FlagConfigDir("./") + logConfigPath = oocc.FlagLogConfigFilePath("") flag.Parse() - cc.SetConfigPath(*configPath) - if err := cc.Load(&config.Config, ConfigFileName); nil != err { - panic(err) + logging.InitializeLogger(*logConfigPath) + + cc.SetConfigPath(*configDir) + if err := cc.Load(&config.Config, oocc.ConfigFileName); nil != err { + logging.Logger().Panic(err) } } diff --git a/module/member/reset_password.go b/module/member/reset_password.go index 0d2fdd8..d28fe50 100644 --- a/module/member/reset_password.go +++ b/module/member/reset_password.go @@ -4,10 +4,10 @@ import ( "context" "encoding/json" "fmt" - "log" "net/url" "strings" + "git.loafle.net/commons_go/logging" "git.loafle.net/overflow/overflow_server_app/external/grpc" "github.com/valyala/fasthttp" ) @@ -30,7 +30,7 @@ func ResetPassword(ctx *fasthttp.RequestCtx) { length := len(webParams) if length < 0 { - fmt.Println("eeee") + logging.Logger().Errorf("eeee") } jsonMap := webParams[0].(map[string]interface{}) @@ -49,6 +49,6 @@ func ResetPassword(ctx *fasthttp.RequestCtx) { r, err := grpc.Exec(gRPCCtx, "MemberService.resetPassword", grpcParams) ctx.SetContentType("application/javascript") - log.Printf("M:%s", r) + logging.Logger().Debugf("M:%s", r) ctx.SetBody([]byte(r)) } diff --git a/module/member/signin.go b/module/member/signin.go index ab6a06d..237309b 100644 --- a/module/member/signin.go +++ b/module/member/signin.go @@ -164,7 +164,7 @@ func SigninByCookie(ctx *fasthttp.RequestCtx) { var ok bool var claims jwt.MapClaims if claims, ok = token.Claims.(jwt.MapClaims); !ok || !token.Valid { - logging.Logger().Warn(fmt.Sprintf("Webapp: Token is not valid %v", token)) + logging.Logger().Warnf("Webapp: Token is not valid %v", token) err = errors.New("authToken is invalid") commons.SendRESTError(ctx, fasthttp.StatusBadRequest, err)