From 5a50305c0dd4d2375c4ac3f79fcdcfd73bc5e5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20=C3=81lvarez?= <86166683+ralvarezdev@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:23:50 -0400 Subject: [PATCH] refactor: removed unnecessary check --- cloud/gcloud/logger.go | 11 ++++------- env/logger.go | 11 ++++------- http/listener/logger.go | 11 ++++------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/cloud/gcloud/logger.go b/cloud/gcloud/logger.go index 601e7fc..48f6ac9 100644 --- a/cloud/gcloud/logger.go +++ b/cloud/gcloud/logger.go @@ -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" @@ -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 } diff --git a/env/logger.go b/env/logger.go index 27281dd..217963a 100644 --- a/env/logger.go +++ b/env/logger.go @@ -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" ) @@ -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 } diff --git a/http/listener/logger.go b/http/listener/logger.go index d1414c2..67ff994 100644 --- a/http/listener/logger.go +++ b/http/listener/logger.go @@ -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" ) @@ -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 }