Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update golem version #13

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ SERVER_PORT=8081
API_URL=http://gobel-api:8080
SITE_URL=http://localhost:8081
TIME_ZONE=Asia/Tokyo
LOG_THRESHOLD=0 # 0:info 1:warn 2:error 3:fatal
LOG_TIME_ZONE_OFFSET=32400 # 9*60*60

2 changes: 1 addition & 1 deletion app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.15

require (
github.com/bmf-san/goblin v0.0.0-20200812051731-4ca3dc28faa3
github.com/bmf-san/golem v0.0.0-20200718182453-066c8e70e46e
github.com/bmf-san/golem v0.0.0-20201124170718-57b487ad1eb5
)
2 changes: 2 additions & 0 deletions app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/bmf-san/goblin v0.0.0-20200812051731-4ca3dc28faa3 h1:eidWLsul6JXYNrV6
github.com/bmf-san/goblin v0.0.0-20200812051731-4ca3dc28faa3/go.mod h1:/rc0S2icYigzs9pjMRyCfYj9xHEREpVKqll+6LLz15w=
github.com/bmf-san/golem v0.0.0-20200718182453-066c8e70e46e h1:WSywsXMGFUlb5LPQQ9C3diiL11keP+m59rPPz5ZnOo0=
github.com/bmf-san/golem v0.0.0-20200718182453-066c8e70e46e/go.mod h1:WO0mipXeyFiPkU+4uLuovMQtMZLf4VtrrJyXpdcZYoQ=
github.com/bmf-san/golem v0.0.0-20201124170718-57b487ad1eb5 h1:nz15EhpQ6Yh6mexMUy2nRJnWX5EEOqV9QXz7aqasqH4=
github.com/bmf-san/golem v0.0.0-20201124170718-57b487ad1eb5/go.mod h1:WO0mipXeyFiPkU+4uLuovMQtMZLf4VtrrJyXpdcZYoQ=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
Expand Down
6 changes: 4 additions & 2 deletions app/logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package logger

import (
"time"

"github.com/bmf-san/golem"
)

Expand All @@ -10,9 +12,9 @@ type Logger struct {
}

// NewLogger creates a logger.
func NewLogger() *Logger {
func NewLogger(threshold int, location *time.Location) *Logger {
return &Logger{
logger: golem.NewLogger(),
logger: golem.NewLogger(threshold, location),
}
}

Expand Down
16 changes: 6 additions & 10 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"net/http"
"os"
"strconv"
"time"

"github.com/bmf-san/gobel-client-example/app/api"
Expand All @@ -12,17 +13,12 @@ import (
"github.com/bmf-san/goblin"
)

func init() {
location := os.Getenv("TIME_ZONE")
loc, err := time.LoadLocation(location)
if err != nil {
loc = time.FixedZone(location, 9*60*60)
}
time.Local = loc
}

func main() {
logger := logger.NewLogger()
threshold, _ := strconv.Atoi(os.Getenv("LOG_THRESHOLD"))
offset, _ := strconv.Atoi(os.Getenv("LOG_TIME_ZONE_OFFSET"))
location := time.FixedZone(os.Getenv("TIME_ZONE"), offset)

logger := logger.NewLogger(threshold, location)
client := api.NewClient()
response := response.NewResponse()

Expand Down