Skip to content

Commit

Permalink
refactor: removed unnecessary check
Browse files Browse the repository at this point in the history
  • Loading branch information
ralvarezdev committed Jan 5, 2025
1 parent b5a27f0 commit 5a50305
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
11 changes: 4 additions & 7 deletions cloud/gcloud/logger.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gcloud

import (
gologger "github.com/ralvarezdev/go-logger"
gologgermode "github.com/ralvarezdev/go-logger/mode"
gologgermodenamed "github.com/ralvarezdev/go-logger/mode/named"
"google.golang.org/grpc/credentials/oauth"
Expand All @@ -14,13 +13,11 @@ type Logger struct {

// NewLogger is the logger for Google Cloud
func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error) {
// Check if the logger is nil
if modeLogger == nil {
return nil, gologger.ErrNilLogger
}

// Initialize the mode named logger
namedLogger, _ := gologgermodenamed.NewDefaultLogger(header, modeLogger)
namedLogger, err := gologgermodenamed.NewDefaultLogger(header, modeLogger)
if err != nil {
return nil, err
}

return &Logger{logger: namedLogger}, nil
}
Expand Down
11 changes: 4 additions & 7 deletions env/logger.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package env

import (
gologger "github.com/ralvarezdev/go-logger"
gologgermode "github.com/ralvarezdev/go-logger/mode"
gologgermodenamed "github.com/ralvarezdev/go-logger/mode/named"
)
Expand All @@ -13,13 +12,11 @@ type Logger struct {

// NewLogger creates a new environment logger
func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error) {
// Check if the logger is nil
if modeLogger == nil {
return nil, gologger.ErrNilLogger
}

// Initialize the mode named logger
namedLogger, _ := gologgermodenamed.NewDefaultLogger(header, modeLogger)
namedLogger, err := gologgermodenamed.NewDefaultLogger(header, modeLogger)
if err != nil {
return nil, err
}

return &Logger{logger: namedLogger}, nil
}
Expand Down
11 changes: 4 additions & 7 deletions http/listener/logger.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package listener

import (
gologger "github.com/ralvarezdev/go-logger"
gologgermode "github.com/ralvarezdev/go-logger/mode"
gologgermodenamed "github.com/ralvarezdev/go-logger/mode/named"
)
Expand All @@ -13,13 +12,11 @@ type Logger struct {

// NewLogger creates a new listener logger
func NewLogger(header string, modeLogger gologgermode.Logger) (*Logger, error) {
// Check if the logger is nil
if modeLogger == nil {
return nil, gologger.ErrNilLogger
}

// Initialize the mode named logger
namedLogger, _ := gologgermodenamed.NewDefaultLogger(header, modeLogger)
namedLogger, err := gologgermodenamed.NewDefaultLogger(header, modeLogger)
if err != nil {
return nil, err
}

return &Logger{logger: namedLogger}, nil
}
Expand Down

0 comments on commit 5a50305

Please sign in to comment.