Skip to content

Commit

Permalink
chore: logger: seperate error log output (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
crlssn authored Dec 18, 2024
1 parent 0eaef2d commit 15077ff
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"github.com/bufbuild/protovalidate-go"
"github.com/joho/godotenv"
"go.uber.org/fx"
"go.uber.org/zap"

"github.com/crlssn/getstronger/server/bus"
"github.com/crlssn/getstronger/server/pkg/config"
"github.com/crlssn/getstronger/server/pkg/cookies"
"github.com/crlssn/getstronger/server/pkg/db"
"github.com/crlssn/getstronger/server/pkg/email"
"github.com/crlssn/getstronger/server/pkg/jwt"
"github.com/crlssn/getstronger/server/pkg/logger"
"github.com/crlssn/getstronger/server/pkg/repo"
"github.com/crlssn/getstronger/server/pkg/stream"
"github.com/crlssn/getstronger/server/pkg/trace"
Expand All @@ -33,9 +33,9 @@ func options() []fx.Option {
db.Module(),
bus.Module(),
jwt.Module(),
logger.Module(),
server.Module(),
fx.Provide(
zap.NewDevelopment,
repo.New,
email.New,
trace.New,
Expand Down
30 changes: 30 additions & 0 deletions server/pkg/logger/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package logger

import (
"go.uber.org/fx"
"go.uber.org/zap"
)

func Module() fx.Option {
return fx.Module("logger", fx.Options(
fx.Provide(
func() zap.Config {
return zap.Config{
Level: zap.NewAtomicLevelAt(zap.InfoLevel),
Development: false,
Sampling: &zap.SamplingConfig{
Initial: 100, //nolint:mnd
Thereafter: 100, //nolint:mnd
},
Encoding: "json",
EncoderConfig: zap.NewProductionEncoderConfig(),
OutputPaths: []string{"stdout"},
ErrorOutputPaths: []string{"stderr"},
}
},
func(config zap.Config) (*zap.Logger, error) {
return config.Build()
},
),
))
}

0 comments on commit 15077ff

Please sign in to comment.