fix: mongo cfg
This commit is contained in:
parent
354890ece1
commit
050fe16f54
|
|
@ -86,7 +86,7 @@ func main() {
|
|||
|
||||
logger := customlogger.NewLogger(cfg.Env, cfg.LogLevel)
|
||||
|
||||
domain.MongoDBLogger, err = mongoLogger.InitLogger()
|
||||
domain.MongoDBLogger, err = mongoLogger.InitLogger(cfg)
|
||||
if err != nil {
|
||||
log.Fatalf("Logger initialization failed: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,18 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/SamuelTariku/FortuneBet-Backend/internal/config"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
func InitLogger() (*zap.Logger, error) {
|
||||
func InitLogger(cfg *config.Config) (*zap.Logger, error) {
|
||||
mongoCore, err := NewMongoCore(
|
||||
os.Getenv("MONGODB_URL"),
|
||||
"logdb",
|
||||
"applogs",
|
||||
zapcore.InfoLevel,
|
||||
cfg,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create MongoDB core: %w", err)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ type MongoCore struct {
|
|||
cfg *config.Config
|
||||
}
|
||||
|
||||
func NewMongoCore(uri, dbName, collectionName string, level zapcore.Level) (zapcore.Core, error) {
|
||||
func NewMongoCore(uri, dbName, collectionName string, level zapcore.Level, cfg *config.Config) (zapcore.Core, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
|
@ -38,6 +38,7 @@ func NewMongoCore(uri, dbName, collectionName string, level zapcore.Level) (zapc
|
|||
return &MongoCore{
|
||||
collection: coll,
|
||||
level: level,
|
||||
cfg: cfg,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ func (s *Service) GenerateTicketOutcome(ctx context.Context, eventID int64, mark
|
|||
|
||||
func (s *Service) CreateTicket(ctx context.Context, req domain.CreateTicketReq, clientIP string) (domain.Ticket, int64, error) {
|
||||
|
||||
s.mongoLogger.Info("Creating ticket")
|
||||
// s.mongoLogger.Info("Creating ticket")
|
||||
// TODO Validate Outcomes Here and make sure they didn't expire
|
||||
// Validation for creating tickets
|
||||
if len(req.Outcomes) > 30 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user