diff --git a/api/config.go b/api/config.go index cbdd26b..57f8155 100644 --- a/api/config.go +++ b/api/config.go @@ -5,15 +5,15 @@ import ( "time" "github.com/Kyagara/equinox/cache" - "go.uber.org/zap/zapcore" + "github.com/rs/zerolog" ) // Configuration for the Equinox client. type EquinoxConfig struct { // Riot API Key. Key string - // Log level. - LogLevel LogLevel + // Zerolog log level. + LogLevel zerolog.Level // http.Client used internally. HTTPClient *http.Client // Retry a request n times if it returns a 429 status code. @@ -22,17 +22,12 @@ type EquinoxConfig struct { Cache *cache.Cache } -func (c *EquinoxConfig) MarshalLogObject(encoder zapcore.ObjectEncoder) error { - encoder.AddInt("retry-if-429", c.Retry) - encoder.AddDuration("http-client-timeout", c.HTTPClient.Timeout) +func (c EquinoxConfig) MarshalZerologObject(encoder *zerolog.Event) { + encoder.Int("retry-if-429", c.Retry).Dur("http-client-timeout", c.HTTPClient.Timeout) if c.Cache.TTL > 0 { cache := CacheConfig{Store: string(c.Cache.StoreType), TTL: c.Cache.TTL} - err := encoder.AddObject("cache", cache) - if err != nil { - return err - } + encoder.Object("cache", cache) } - return nil } type CacheConfig struct { @@ -40,8 +35,6 @@ type CacheConfig struct { Store string } -func (c CacheConfig) MarshalLogObject(encoder zapcore.ObjectEncoder) error { - encoder.AddString("store", c.Store) - encoder.AddDuration("cache-ttl", c.TTL) - return nil +func (c CacheConfig) MarshalZerologObject(encoder *zerolog.Event) { + encoder.Str("store", c.Store).Dur("cache-ttl", c.TTL) } diff --git a/api/constants.go b/api/constants.go index 746ec00..358ab36 100644 --- a/api/constants.go +++ b/api/constants.go @@ -13,12 +13,12 @@ package api import ( "net/http" - "go.uber.org/zap" + "github.com/rs/zerolog" ) // EquinoxRequest represents a request to the Riot API and CDNs, its a struct that contains all information about a request. type EquinoxRequest struct { - Logger *zap.Logger + Logger zerolog.Logger MethodID string Route any BaseURL string @@ -37,21 +37,6 @@ const ( C_DRAGON_BASE_URL_FORMAT = "https://cdn.communitydragon.org%s" ) -type LogLevel int8 - -const ( - // NOP_LOG_LEVEL won't log anything, this is the default behaviour for the Default client. - NOP_LOG_LEVEL LogLevel = iota - 2 - // DEBUG_LOG_LEVEL will log everything. - DEBUG_LOG_LEVEL - // INFO_LOG_LEVEL will log the requests being made and if they were successful. - INFO_LOG_LEVEL - // WARN_LOG_LEVEL will log when a request was rate limited. - WARN_LOG_LEVEL - // ERROR_LOG_LEVEL will log every error. - ERROR_LOG_LEVEL -) - // Regional routes, used in tournament services, Legends of Runeterra (LoR), and some other endpoints. type RegionalRoute string diff --git a/clients/cdragon/champion.go b/clients/cdragon/champion.go index 63f464a..23ac372 100644 --- a/clients/cdragon/champion.go +++ b/clients/cdragon/champion.go @@ -7,7 +7,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) type ChampionEndpoint struct { @@ -122,16 +121,16 @@ type ChampionData struct { // Retrieves more information about a champion, includes skins, spells and tips. func (e *ChampionEndpoint) ByName(ctx context.Context, version string, champion string) (*ChampionData, error) { logger := e.internal.Logger("CDragon_Champion_ByName") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.C_DRAGON_BASE_URL_FORMAT, http.MethodGet, "", fmt.Sprintf(ChampionURL, version, champion), "", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ChampionData err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } return &data, nil @@ -140,16 +139,16 @@ func (e *ChampionEndpoint) ByName(ctx context.Context, version string, champion // Retrieves more information about a champion, includes skins, spells and tips. func (e *ChampionEndpoint) ByID(ctx context.Context, version string, id int) (*ChampionData, error) { logger := e.internal.Logger("CDragon_Champion_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.C_DRAGON_BASE_URL_FORMAT, http.MethodGet, "", fmt.Sprintf(ChampionURL, version, id), "", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ChampionData err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } return &data, nil diff --git a/clients/ddragon/champion.go b/clients/ddragon/champion.go index 0aa09d5..ccf30ed 100644 --- a/clients/ddragon/champion.go +++ b/clients/ddragon/champion.go @@ -7,7 +7,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) type ChampionEndpoint struct { @@ -145,16 +144,16 @@ type Image struct { // Get all champions basic information, includes stats, tags, title and blurb. func (e *ChampionEndpoint) AllChampions(ctx context.Context, version string, language Language) (map[string]Champion, error) { logger := e.internal.Logger("DDragon_Champion_AllChampions") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.D_DRAGON_BASE_URL_FORMAT, http.MethodGet, "", fmt.Sprintf(ChampionsURL, version, language), "", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ChampionsData err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } return data.Data, nil @@ -163,16 +162,16 @@ func (e *ChampionEndpoint) AllChampions(ctx context.Context, version string, lan // Retrieves more information about a champion, includes skins, spells and tips. func (e *ChampionEndpoint) ByName(ctx context.Context, version string, language Language, champion string) (*FullChampion, error) { logger := e.internal.Logger("DDragon_Champion_ByName") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.D_DRAGON_BASE_URL_FORMAT, http.MethodGet, "", fmt.Sprintf(ChampionURL, version, language, champion), "", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data FullChampionData err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } c := data.Data[champion] diff --git a/clients/ddragon/realms.go b/clients/ddragon/realms.go index 2f3dc3d..4c0d1a1 100644 --- a/clients/ddragon/realms.go +++ b/clients/ddragon/realms.go @@ -7,7 +7,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) type RealmEndpoint struct { @@ -38,16 +37,16 @@ type RealmData struct { func (e *RealmEndpoint) ByName(ctx context.Context, realm Realm) (*RealmData, error) { logger := e.internal.Logger("DDragon_Realm_ByName") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.D_DRAGON_BASE_URL_FORMAT, http.MethodGet, "", fmt.Sprintf(RealmURL, realm), "", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data RealmData err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } return &data, nil diff --git a/clients/lol/endpoints.go b/clients/lol/endpoints.go index 149c5a7..56661e9 100644 --- a/clients/lol/endpoints.go +++ b/clients/lol/endpoints.go @@ -17,7 +17,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) // # Riot API Reference @@ -46,19 +45,19 @@ type ChampionMasteryV4 struct { // [champion-mastery-v4.getAllChampionMasteriesByPUUID]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteriesByPUUID func (e *ChampionMasteryV4) AllMasteriesByPUUID(ctx context.Context, route PlatformRoute, encryptedPUUID string) ([]ChampionMasteryV4DTO, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_AllMasteriesByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/champion-masteries/by-puuid/%v", encryptedPUUID), "champion-mastery-v4.getAllChampionMasteriesByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]ChampionMasteryV4DTO), err } var data []ChampionMasteryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]ChampionMasteryV4DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -78,19 +77,19 @@ func (e *ChampionMasteryV4) AllMasteriesByPUUID(ctx context.Context, route Platf // [champion-mastery-v4.getChampionMasteryByPUUID]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMasteryByPUUID func (e *ChampionMasteryV4) MasteryByPUUID(ctx context.Context, route PlatformRoute, encryptedPUUID string, championId int64) (*ChampionMasteryV4DTO, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_MasteryByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/champion-masteries/by-puuid/%v/by-champion/%v", encryptedPUUID, championId), "champion-mastery-v4.getChampionMasteryByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ChampionMasteryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -110,10 +109,10 @@ func (e *ChampionMasteryV4) MasteryByPUUID(ctx context.Context, route PlatformRo // [champion-mastery-v4.getTopChampionMasteriesByPUUID]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getTopChampionMasteriesByPUUID func (e *ChampionMasteryV4) TopMasteriesByPUUID(ctx context.Context, route PlatformRoute, encryptedPUUID string, count int32) ([]ChampionMasteryV4DTO, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_TopMasteriesByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/champion-masteries/by-puuid/%v/top", encryptedPUUID), "champion-mastery-v4.getTopChampionMasteriesByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]ChampionMasteryV4DTO), err } values := equinoxReq.Request.URL.Query() @@ -124,10 +123,10 @@ func (e *ChampionMasteryV4) TopMasteriesByPUUID(ctx context.Context, route Platf var data []ChampionMasteryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]ChampionMasteryV4DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -146,19 +145,19 @@ func (e *ChampionMasteryV4) TopMasteriesByPUUID(ctx context.Context, route Platf // [champion-mastery-v4.getAllChampionMasteries]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries func (e *ChampionMasteryV4) AllMasteriesBySummonerID(ctx context.Context, route PlatformRoute, encryptedSummonerId string) ([]ChampionMasteryV4DTO, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_AllMasteriesBySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/champion-masteries/by-summoner/%v", encryptedSummonerId), "champion-mastery-v4.getAllChampionMasteries", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]ChampionMasteryV4DTO), err } var data []ChampionMasteryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]ChampionMasteryV4DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -178,19 +177,19 @@ func (e *ChampionMasteryV4) AllMasteriesBySummonerID(ctx context.Context, route // [champion-mastery-v4.getChampionMastery]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMastery func (e *ChampionMasteryV4) MasteryBySummonerID(ctx context.Context, route PlatformRoute, encryptedSummonerId string, championId int64) (*ChampionMasteryV4DTO, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_MasteryBySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/champion-masteries/by-summoner/%v/by-champion/%v", encryptedSummonerId, championId), "champion-mastery-v4.getChampionMastery", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ChampionMasteryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -210,10 +209,10 @@ func (e *ChampionMasteryV4) MasteryBySummonerID(ctx context.Context, route Platf // [champion-mastery-v4.getTopChampionMasteries]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getTopChampionMasteries func (e *ChampionMasteryV4) TopMasteriesBySummonerID(ctx context.Context, route PlatformRoute, encryptedSummonerId string, count int32) ([]ChampionMasteryV4DTO, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_TopMasteriesBySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/champion-masteries/by-summoner/%v/top", encryptedSummonerId), "champion-mastery-v4.getTopChampionMasteries", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]ChampionMasteryV4DTO), err } values := equinoxReq.Request.URL.Query() @@ -224,10 +223,10 @@ func (e *ChampionMasteryV4) TopMasteriesBySummonerID(ctx context.Context, route var data []ChampionMasteryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]ChampionMasteryV4DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -246,19 +245,19 @@ func (e *ChampionMasteryV4) TopMasteriesBySummonerID(ctx context.Context, route // [champion-mastery-v4.getChampionMasteryScoreByPUUID]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMasteryScoreByPUUID func (e *ChampionMasteryV4) MasteryScoreByPUUID(ctx context.Context, route PlatformRoute, encryptedPUUID string) (int32, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_MasteryScoreByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/scores/by-puuid/%v", encryptedPUUID), "champion-mastery-v4.getChampionMasteryScoreByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(int32), err } var data int32 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(int32), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -277,19 +276,19 @@ func (e *ChampionMasteryV4) MasteryScoreByPUUID(ctx context.Context, route Platf // [champion-mastery-v4.getChampionMasteryScore]: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getChampionMasteryScore func (e *ChampionMasteryV4) ScoreBySummonerID(ctx context.Context, route PlatformRoute, encryptedSummonerId string) (int32, error) { logger := e.internal.Logger("LOL_ChampionMasteryV4_ScoreBySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/champion-mastery/v4/scores/by-summoner/%v", encryptedSummonerId), "champion-mastery-v4.getChampionMasteryScore", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(int32), err } var data int32 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(int32), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -318,19 +317,19 @@ type ChampionV3 struct { // [champion-v3.getChampionInfo]: https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo func (e *ChampionV3) Rotation(ctx context.Context, route PlatformRoute) (*ChampionRotationV3DTO, error) { logger := e.internal.Logger("LOL_ChampionV3_Rotation") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/platform/v3/champion-rotations", "champion-v3.getChampionInfo", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ChampionRotationV3DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -364,19 +363,19 @@ type ClashV1 struct { // [clash-v1.getPlayersBySummoner]: https://developer.riotgames.com/api-methods/#clash-v1/GET_getPlayersBySummoner func (e *ClashV1) SummonerEntriesBySummonerID(ctx context.Context, route PlatformRoute, summonerId string) ([]PlayerV1DTO, error) { logger := e.internal.Logger("LOL_ClashV1_SummonerEntriesBySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/clash/v1/players/by-summoner/%v", summonerId), "clash-v1.getPlayersBySummoner", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]PlayerV1DTO), err } var data []PlayerV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]PlayerV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -395,19 +394,19 @@ func (e *ClashV1) SummonerEntriesBySummonerID(ctx context.Context, route Platfor // [clash-v1.getTeamById]: https://developer.riotgames.com/api-methods/#clash-v1/GET_getTeamById func (e *ClashV1) TeamByTeamID(ctx context.Context, route PlatformRoute, teamId string) (*TeamV1DTO, error) { logger := e.internal.Logger("LOL_ClashV1_TeamByTeamID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/clash/v1/teams/%v", teamId), "clash-v1.getTeamById", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data TeamV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -425,19 +424,19 @@ func (e *ClashV1) TeamByTeamID(ctx context.Context, route PlatformRoute, teamId // [clash-v1.getTournaments]: https://developer.riotgames.com/api-methods/#clash-v1/GET_getTournaments func (e *ClashV1) Tournaments(ctx context.Context, route PlatformRoute) ([]TournamentV1DTO, error) { logger := e.internal.Logger("LOL_ClashV1_Tournaments") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/clash/v1/tournaments", "clash-v1.getTournaments", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]TournamentV1DTO), err } var data []TournamentV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]TournamentV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -456,19 +455,19 @@ func (e *ClashV1) Tournaments(ctx context.Context, route PlatformRoute) ([]Tourn // [clash-v1.getTournamentByTeam]: https://developer.riotgames.com/api-methods/#clash-v1/GET_getTournamentByTeam func (e *ClashV1) ByTeamID(ctx context.Context, route PlatformRoute, teamId string) (*TournamentV1DTO, error) { logger := e.internal.Logger("LOL_ClashV1_ByTeamID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/clash/v1/tournaments/by-team/%v", teamId), "clash-v1.getTournamentByTeam", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data TournamentV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -487,19 +486,19 @@ func (e *ClashV1) ByTeamID(ctx context.Context, route PlatformRoute, teamId stri // [clash-v1.getTournamentById]: https://developer.riotgames.com/api-methods/#clash-v1/GET_getTournamentById func (e *ClashV1) ByID(ctx context.Context, route PlatformRoute, tournamentId int32) (*TournamentV1DTO, error) { logger := e.internal.Logger("LOL_ClashV1_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/clash/v1/tournaments/%v", tournamentId), "clash-v1.getTournamentById", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data TournamentV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -532,10 +531,10 @@ type LeagueExpV4 struct { // [league-exp-v4.getLeagueEntries]: https://developer.riotgames.com/api-methods/#league-exp-v4/GET_getLeagueEntries func (e *LeagueExpV4) Entries(ctx context.Context, route PlatformRoute, queue QueueType, tier Tier, division Division, page int32) ([]LeagueEntryV4DTO, error) { logger := e.internal.Logger("LOL_LeagueExpV4_Entries") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/league-exp/v4/entries/%v/%v/%v", queue, tier, division), "league-exp-v4.getLeagueEntries", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]LeagueEntryV4DTO), err } values := equinoxReq.Request.URL.Query() @@ -546,10 +545,10 @@ func (e *LeagueExpV4) Entries(ctx context.Context, route PlatformRoute, queue Qu var data []LeagueEntryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]LeagueEntryV4DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -579,19 +578,19 @@ type LeagueV4 struct { // [league-v4.getChallengerLeague]: https://developer.riotgames.com/api-methods/#league-v4/GET_getChallengerLeague func (e *LeagueV4) ChallengerByQueue(ctx context.Context, route PlatformRoute, queue QueueType) (*LeagueListV4DTO, error) { logger := e.internal.Logger("LOL_LeagueV4_ChallengerByQueue") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/league/v4/challengerleagues/by-queue/%v", queue), "league-v4.getChallengerLeague", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data LeagueListV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -610,19 +609,19 @@ func (e *LeagueV4) ChallengerByQueue(ctx context.Context, route PlatformRoute, q // [league-v4.getLeagueEntriesForSummoner]: https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueEntriesForSummoner func (e *LeagueV4) SummonerEntries(ctx context.Context, route PlatformRoute, encryptedSummonerId string) ([]LeagueEntryV4DTO, error) { logger := e.internal.Logger("LOL_LeagueV4_SummonerEntries") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/league/v4/entries/by-summoner/%v", encryptedSummonerId), "league-v4.getLeagueEntriesForSummoner", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]LeagueEntryV4DTO), err } var data []LeagueEntryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]LeagueEntryV4DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -644,10 +643,10 @@ func (e *LeagueV4) SummonerEntries(ctx context.Context, route PlatformRoute, enc // [league-v4.getLeagueEntries]: https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueEntries func (e *LeagueV4) Entries(ctx context.Context, route PlatformRoute, queue QueueType, tier Tier, division Division, page int32) ([]LeagueEntryV4DTO, error) { logger := e.internal.Logger("LOL_LeagueV4_Entries") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/league/v4/entries/%v/%v/%v", queue, tier, division), "league-v4.getLeagueEntries", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]LeagueEntryV4DTO), err } values := equinoxReq.Request.URL.Query() @@ -658,10 +657,10 @@ func (e *LeagueV4) Entries(ctx context.Context, route PlatformRoute, queue Queue var data []LeagueEntryV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]LeagueEntryV4DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -680,19 +679,19 @@ func (e *LeagueV4) Entries(ctx context.Context, route PlatformRoute, queue Queue // [league-v4.getGrandmasterLeague]: https://developer.riotgames.com/api-methods/#league-v4/GET_getGrandmasterLeague func (e *LeagueV4) GrandmasterByQueue(ctx context.Context, route PlatformRoute, queue QueueType) (*LeagueListV4DTO, error) { logger := e.internal.Logger("LOL_LeagueV4_GrandmasterByQueue") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/league/v4/grandmasterleagues/by-queue/%v", queue), "league-v4.getGrandmasterLeague", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data LeagueListV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -711,19 +710,19 @@ func (e *LeagueV4) GrandmasterByQueue(ctx context.Context, route PlatformRoute, // [league-v4.getLeagueById]: https://developer.riotgames.com/api-methods/#league-v4/GET_getLeagueById func (e *LeagueV4) ByID(ctx context.Context, route PlatformRoute, leagueId string) (*LeagueListV4DTO, error) { logger := e.internal.Logger("LOL_LeagueV4_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/league/v4/leagues/%v", leagueId), "league-v4.getLeagueById", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data LeagueListV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -742,19 +741,19 @@ func (e *LeagueV4) ByID(ctx context.Context, route PlatformRoute, leagueId strin // [league-v4.getMasterLeague]: https://developer.riotgames.com/api-methods/#league-v4/GET_getMasterLeague func (e *LeagueV4) MasterByQueue(ctx context.Context, route PlatformRoute, queue QueueType) (*LeagueListV4DTO, error) { logger := e.internal.Logger("LOL_LeagueV4_MasterByQueue") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/league/v4/masterleagues/by-queue/%v", queue), "league-v4.getMasterLeague", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data LeagueListV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -783,19 +782,19 @@ type ChallengesV1 struct { // [lol-challenges-v1.getAllChallengeConfigs]: https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getAllChallengeConfigs func (e *ChallengesV1) AllConfigs(ctx context.Context, route PlatformRoute) ([]ChallengeConfigInfoV1DTO, error) { logger := e.internal.Logger("LOL_ChallengesV1_AllConfigs") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/challenges/v1/challenges/config", "lol-challenges-v1.getAllChallengeConfigs", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]ChallengeConfigInfoV1DTO), err } var data []ChallengeConfigInfoV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]ChallengeConfigInfoV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -813,19 +812,19 @@ func (e *ChallengesV1) AllConfigs(ctx context.Context, route PlatformRoute) ([]C // [lol-challenges-v1.getAllChallengePercentiles]: https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getAllChallengePercentiles func (e *ChallengesV1) AllPercentiles(ctx context.Context, route PlatformRoute) (map[int64]map[Tier]float64, error) { logger := e.internal.Logger("LOL_ChallengesV1_AllPercentiles") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/challenges/v1/challenges/percentiles", "lol-challenges-v1.getAllChallengePercentiles", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(map[int64]map[Tier]float64), err } var data map[int64]map[Tier]float64 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(map[int64]map[Tier]float64), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -844,19 +843,19 @@ func (e *ChallengesV1) AllPercentiles(ctx context.Context, route PlatformRoute) // [lol-challenges-v1.getChallengeConfigs]: https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getChallengeConfigs func (e *ChallengesV1) ConfigByID(ctx context.Context, route PlatformRoute, challengeId int64) (*ChallengeConfigInfoV1DTO, error) { logger := e.internal.Logger("LOL_ChallengesV1_ConfigByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/challenges/v1/challenges/%v/config", challengeId), "lol-challenges-v1.getChallengeConfigs", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ChallengeConfigInfoV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -877,10 +876,10 @@ func (e *ChallengesV1) ConfigByID(ctx context.Context, route PlatformRoute, chal // [lol-challenges-v1.getChallengeLeaderboards]: https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getChallengeLeaderboards func (e *ChallengesV1) Leaderboards(ctx context.Context, route PlatformRoute, challengeId int64, level Tier, limit int32) ([]ApexPlayerInfoV1DTO, error) { logger := e.internal.Logger("LOL_ChallengesV1_Leaderboards") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/challenges/v1/challenges/%v/leaderboards/by-level/%v", challengeId, level), "lol-challenges-v1.getChallengeLeaderboards", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]ApexPlayerInfoV1DTO), err } values := equinoxReq.Request.URL.Query() @@ -891,10 +890,10 @@ func (e *ChallengesV1) Leaderboards(ctx context.Context, route PlatformRoute, ch var data []ApexPlayerInfoV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]ApexPlayerInfoV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -913,19 +912,19 @@ func (e *ChallengesV1) Leaderboards(ctx context.Context, route PlatformRoute, ch // [lol-challenges-v1.getChallengePercentiles]: https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getChallengePercentiles func (e *ChallengesV1) Percentiles(ctx context.Context, route PlatformRoute, challengeId int64) (map[Tier]float64, error) { logger := e.internal.Logger("LOL_ChallengesV1_Percentiles") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/challenges/v1/challenges/%v/percentiles", challengeId), "lol-challenges-v1.getChallengePercentiles", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(map[Tier]float64), err } var data map[Tier]float64 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(map[Tier]float64), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -944,19 +943,19 @@ func (e *ChallengesV1) Percentiles(ctx context.Context, route PlatformRoute, cha // [lol-challenges-v1.getPlayerData]: https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getPlayerData func (e *ChallengesV1) ByPUUID(ctx context.Context, route PlatformRoute, puuid string) (*PlayerInfoV1DTO, error) { logger := e.internal.Logger("LOL_ChallengesV1_ByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/challenges/v1/player-data/%v", puuid), "lol-challenges-v1.getPlayerData", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data PlayerInfoV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -989,19 +988,19 @@ type StatusV3 struct { // [lol-status-v3.getShardData]: https://developer.riotgames.com/api-methods/#lol-status-v3/GET_getShardData func (e *StatusV3) Shard(ctx context.Context, route PlatformRoute) (*ShardStatusV3DTO, error) { logger := e.internal.Logger("LOL_StatusV3_Shard") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/status/v3/shard-data", "lol-status-v3.getShardData", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ShardStatusV3DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1030,19 +1029,19 @@ type StatusV4 struct { // [lol-status-v4.getPlatformData]: https://developer.riotgames.com/api-methods/#lol-status-v4/GET_getPlatformData func (e *StatusV4) Platform(ctx context.Context, route PlatformRoute) (*PlatformDataV4DTO, error) { logger := e.internal.Logger("LOL_StatusV4_Platform") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/status/v4/platform-data", "lol-status-v4.getPlatformData", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data PlatformDataV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1078,10 +1077,10 @@ type MatchV5 struct { // [match-v5.getMatchIdsByPUUID]: https://developer.riotgames.com/api-methods/#match-v5/GET_getMatchIdsByPUUID func (e *MatchV5) ListByPUUID(ctx context.Context, route api.RegionalRoute, puuid string, startTime int64, endTime int64, queue int32, type_ string, start int32, count int32) ([]string, error) { logger := e.internal.Logger("LOL_MatchV5_ListByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/match/v5/matches/by-puuid/%v/ids", puuid), "match-v5.getMatchIdsByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]string), err } values := equinoxReq.Request.URL.Query() @@ -1107,10 +1106,10 @@ func (e *MatchV5) ListByPUUID(ctx context.Context, route api.RegionalRoute, puui var data []string err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]string), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -1129,19 +1128,19 @@ func (e *MatchV5) ListByPUUID(ctx context.Context, route api.RegionalRoute, puui // [match-v5.getMatch]: https://developer.riotgames.com/api-methods/#match-v5/GET_getMatch func (e *MatchV5) ByID(ctx context.Context, route api.RegionalRoute, matchId string) (*MatchV5DTO, error) { logger := e.internal.Logger("LOL_MatchV5_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/match/v5/matches/%v", matchId), "match-v5.getMatch", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data MatchV5DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1160,19 +1159,19 @@ func (e *MatchV5) ByID(ctx context.Context, route api.RegionalRoute, matchId str // [match-v5.getTimeline]: https://developer.riotgames.com/api-methods/#match-v5/GET_getTimeline func (e *MatchV5) Timeline(ctx context.Context, route api.RegionalRoute, matchId string) (*MatchTimelineV5DTO, error) { logger := e.internal.Logger("LOL_MatchV5_Timeline") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/match/v5/matches/%v/timeline", matchId), "match-v5.getTimeline", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data MatchTimelineV5DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1202,19 +1201,19 @@ type SpectatorV4 struct { // [spectator-v4.getCurrentGameInfoBySummoner]: https://developer.riotgames.com/api-methods/#spectator-v4/GET_getCurrentGameInfoBySummoner func (e *SpectatorV4) CurrentGameBySummonerID(ctx context.Context, route PlatformRoute, encryptedSummonerId string) (*CurrentGameInfoV4DTO, error) { logger := e.internal.Logger("LOL_SpectatorV4_CurrentGameBySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/spectator/v4/active-games/by-summoner/%v", encryptedSummonerId), "spectator-v4.getCurrentGameInfoBySummoner", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data CurrentGameInfoV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1232,19 +1231,19 @@ func (e *SpectatorV4) CurrentGameBySummonerID(ctx context.Context, route Platfor // [spectator-v4.getFeaturedGames]: https://developer.riotgames.com/api-methods/#spectator-v4/GET_getFeaturedGames func (e *SpectatorV4) Featured(ctx context.Context, route PlatformRoute) (*FeaturedGamesV4DTO, error) { logger := e.internal.Logger("LOL_SpectatorV4_Featured") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/spectator/v4/featured-games", "spectator-v4.getFeaturedGames", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data FeaturedGamesV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1274,19 +1273,19 @@ type SummonerV4 struct { // [summoner-v4.getByRSOPUUID]: https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByRSOPUUID func (e *SummonerV4) ByRSOPUUID(ctx context.Context, route PlatformRoute, rsoPUUID string) (*SummonerV4DTO, error) { logger := e.internal.Logger("LOL_SummonerV4_ByRSOPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/fulfillment/v1/summoners/by-puuid/%v", rsoPUUID), "summoner-v4.getByRSOPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1305,19 +1304,19 @@ func (e *SummonerV4) ByRSOPUUID(ctx context.Context, route PlatformRoute, rsoPUU // [summoner-v4.getByAccountId]: https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccountId func (e *SummonerV4) ByAccountID(ctx context.Context, route PlatformRoute, encryptedAccountId string) (*SummonerV4DTO, error) { logger := e.internal.Logger("LOL_SummonerV4_ByAccountID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/summoner/v4/summoners/by-account/%v", encryptedAccountId), "summoner-v4.getByAccountId", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1336,19 +1335,19 @@ func (e *SummonerV4) ByAccountID(ctx context.Context, route PlatformRoute, encry // [summoner-v4.getBySummonerName]: https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerName func (e *SummonerV4) ByName(ctx context.Context, route PlatformRoute, summonerName string) (*SummonerV4DTO, error) { logger := e.internal.Logger("LOL_SummonerV4_ByName") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/summoner/v4/summoners/by-name/%v", summonerName), "summoner-v4.getBySummonerName", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1367,19 +1366,19 @@ func (e *SummonerV4) ByName(ctx context.Context, route PlatformRoute, summonerNa // [summoner-v4.getByPUUID]: https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByPUUID func (e *SummonerV4) ByPUUID(ctx context.Context, route PlatformRoute, encryptedPUUID string) (*SummonerV4DTO, error) { logger := e.internal.Logger("LOL_SummonerV4_ByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/summoner/v4/summoners/by-puuid/%v", encryptedPUUID), "summoner-v4.getByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1398,10 +1397,10 @@ func (e *SummonerV4) ByPUUID(ctx context.Context, route PlatformRoute, encrypted // [summoner-v4.getByAccessToken]: https://developer.riotgames.com/api-methods/#summoner-v4/GET_getByAccessToken func (e *SummonerV4) ByAccessToken(ctx context.Context, route PlatformRoute, authorization string) (*SummonerV4DTO, error) { logger := e.internal.Logger("LOL_SummonerV4_ByAccessToken") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lol/summoner/v4/summoners/me", "summoner-v4.getByAccessToken", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } if authorization == "" { @@ -1411,10 +1410,10 @@ func (e *SummonerV4) ByAccessToken(ctx context.Context, route PlatformRoute, aut var data SummonerV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1433,19 +1432,19 @@ func (e *SummonerV4) ByAccessToken(ctx context.Context, route PlatformRoute, aut // [summoner-v4.getBySummonerId]: https://developer.riotgames.com/api-methods/#summoner-v4/GET_getBySummonerId func (e *SummonerV4) BySummonerID(ctx context.Context, route PlatformRoute, encryptedSummonerId string) (*SummonerV4DTO, error) { logger := e.internal.Logger("LOL_SummonerV4_BySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/summoner/v4/summoners/%v", encryptedSummonerId), "summoner-v4.getBySummonerId", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV4DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1476,10 +1475,10 @@ type TournamentStubV5 struct { // [tournament-stub-v5.createTournamentCode]: https://developer.riotgames.com/api-methods/#tournament-stub-v5/POST_createTournamentCode func (e *TournamentStubV5) CreateTournamentCode(ctx context.Context, route api.RegionalRoute, body *StubTournamentCodeParametersV5DTO, count int32, tournamentId int64) ([]string, error) { logger := e.internal.Logger("LOL_TournamentStubV5_CreateTournamentCode") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPost, route, "/lol/tournament-stub/v5/codes", "tournament-stub-v5.createTournamentCode", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]string), err } values := equinoxReq.Request.URL.Query() @@ -1493,10 +1492,10 @@ func (e *TournamentStubV5) CreateTournamentCode(ctx context.Context, route api.R var data []string err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]string), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -1515,19 +1514,19 @@ func (e *TournamentStubV5) CreateTournamentCode(ctx context.Context, route api.R // [tournament-stub-v5.getTournamentCode]: https://developer.riotgames.com/api-methods/#tournament-stub-v5/GET_getTournamentCode func (e *TournamentStubV5) TournamentCode(ctx context.Context, route api.RegionalRoute, tournamentCode string) (*StubTournamentCodeV5DTO, error) { logger := e.internal.Logger("LOL_TournamentStubV5_TournamentCode") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/tournament-stub/v5/codes/%v", tournamentCode), "tournament-stub-v5.getTournamentCode", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data StubTournamentCodeV5DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1546,19 +1545,19 @@ func (e *TournamentStubV5) TournamentCode(ctx context.Context, route api.Regiona // [tournament-stub-v5.getLobbyEventsByCode]: https://developer.riotgames.com/api-methods/#tournament-stub-v5/GET_getLobbyEventsByCode func (e *TournamentStubV5) LobbyEventsByCode(ctx context.Context, route api.RegionalRoute, tournamentCode string) (*StubLobbyEventWrapperV5DTO, error) { logger := e.internal.Logger("LOL_TournamentStubV5_LobbyEventsByCode") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/tournament-stub/v5/lobby-events/by-code/%v", tournamentCode), "tournament-stub-v5.getLobbyEventsByCode", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data StubLobbyEventWrapperV5DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1580,19 +1579,19 @@ func (e *TournamentStubV5) LobbyEventsByCode(ctx context.Context, route api.Regi // [tournament-stub-v5.registerProviderData]: https://developer.riotgames.com/api-methods/#tournament-stub-v5/POST_registerProviderData func (e *TournamentStubV5) RegisterProviderData(ctx context.Context, route api.RegionalRoute, body *StubProviderRegistrationParametersV5DTO) (int32, error) { logger := e.internal.Logger("LOL_TournamentStubV5_RegisterProviderData") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPost, route, "/lol/tournament-stub/v5/providers", "tournament-stub-v5.registerProviderData", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(int32), err } var data int32 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(int32), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -1610,19 +1609,19 @@ func (e *TournamentStubV5) RegisterProviderData(ctx context.Context, route api.R // [tournament-stub-v5.registerTournament]: https://developer.riotgames.com/api-methods/#tournament-stub-v5/POST_registerTournament func (e *TournamentStubV5) RegisterTournament(ctx context.Context, route api.RegionalRoute, body *StubTournamentRegistrationParametersV5DTO) (int32, error) { logger := e.internal.Logger("LOL_TournamentStubV5_RegisterTournament") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPost, route, "/lol/tournament-stub/v5/tournaments", "tournament-stub-v5.registerTournament", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(int32), err } var data int32 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(int32), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -1653,10 +1652,10 @@ type TournamentV5 struct { // [tournament-v5.createTournamentCode]: https://developer.riotgames.com/api-methods/#tournament-v5/POST_createTournamentCode func (e *TournamentV5) CreateTournamentCode(ctx context.Context, route api.RegionalRoute, body *TournamentCodeParametersV5DTO, tournamentId int64, count int32) ([]string, error) { logger := e.internal.Logger("LOL_TournamentV5_CreateTournamentCode") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPost, route, "/lol/tournament/v5/codes", "tournament-v5.createTournamentCode", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]string), err } values := equinoxReq.Request.URL.Query() @@ -1670,10 +1669,10 @@ func (e *TournamentV5) CreateTournamentCode(ctx context.Context, route api.Regio var data []string err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]string), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -1692,19 +1691,19 @@ func (e *TournamentV5) CreateTournamentCode(ctx context.Context, route api.Regio // [tournament-v5.getTournamentCode]: https://developer.riotgames.com/api-methods/#tournament-v5/GET_getTournamentCode func (e *TournamentV5) TournamentCode(ctx context.Context, route api.RegionalRoute, tournamentCode string) (*TournamentCodeV5DTO, error) { logger := e.internal.Logger("LOL_TournamentV5_TournamentCode") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/tournament/v5/codes/%v", tournamentCode), "tournament-v5.getTournamentCode", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data TournamentCodeV5DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1723,19 +1722,19 @@ func (e *TournamentV5) TournamentCode(ctx context.Context, route api.RegionalRou // [tournament-v5.updateCode]: https://developer.riotgames.com/api-methods/#tournament-v5/PUT_updateCode func (e *TournamentV5) UpdateCode(ctx context.Context, route api.RegionalRoute, body *TournamentCodeUpdateParametersV5DTO, tournamentCode string) error { logger := e.internal.Logger("LOL_TournamentV5_UpdateCode") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPut, route, fmt.Sprintf("/lol/tournament/v5/codes/%v", tournamentCode), "tournament-v5.updateCode", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil } err = e.internal.Execute(ctx, equinoxReq, nil) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return nil } @@ -1762,19 +1761,19 @@ func (e *TournamentV5) UpdateCode(ctx context.Context, route api.RegionalRoute, // [tournament-v5.getGames]: https://developer.riotgames.com/api-methods/#tournament-v5/GET_getGames func (e *TournamentV5) Games(ctx context.Context, route api.RegionalRoute, tournamentCode string) ([]TournamentGamesV5DTO, error) { logger := e.internal.Logger("LOL_TournamentV5_Games") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/tournament/v5/games/by-code/%v", tournamentCode), "tournament-v5.getGames", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]TournamentGamesV5DTO), err } var data []TournamentGamesV5DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]TournamentGamesV5DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -1793,19 +1792,19 @@ func (e *TournamentV5) Games(ctx context.Context, route api.RegionalRoute, tourn // [tournament-v5.getLobbyEventsByCode]: https://developer.riotgames.com/api-methods/#tournament-v5/GET_getLobbyEventsByCode func (e *TournamentV5) LobbyEventsByCode(ctx context.Context, route api.RegionalRoute, tournamentCode string) (*LobbyEventWrapperV5DTO, error) { logger := e.internal.Logger("LOL_TournamentV5_LobbyEventsByCode") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lol/tournament/v5/lobby-events/by-code/%v", tournamentCode), "tournament-v5.getLobbyEventsByCode", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data LobbyEventWrapperV5DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -1827,19 +1826,19 @@ func (e *TournamentV5) LobbyEventsByCode(ctx context.Context, route api.Regional // [tournament-v5.registerProviderData]: https://developer.riotgames.com/api-methods/#tournament-v5/POST_registerProviderData func (e *TournamentV5) RegisterProviderData(ctx context.Context, route api.RegionalRoute, body *ProviderRegistrationParametersV5DTO) (int32, error) { logger := e.internal.Logger("LOL_TournamentV5_RegisterProviderData") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPost, route, "/lol/tournament/v5/providers", "tournament-v5.registerProviderData", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(int32), err } var data int32 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(int32), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -1857,18 +1856,18 @@ func (e *TournamentV5) RegisterProviderData(ctx context.Context, route api.Regio // [tournament-v5.registerTournament]: https://developer.riotgames.com/api-methods/#tournament-v5/POST_registerTournament func (e *TournamentV5) RegisterTournament(ctx context.Context, route api.RegionalRoute, body *TournamentRegistrationParametersV5DTO) (int32, error) { logger := e.internal.Logger("LOL_TournamentV5_RegisterTournament") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPost, route, "/lol/tournament/v5/tournaments", "tournament-v5.registerTournament", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(int32), err } var data int32 err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(int32), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } diff --git a/clients/lor/endpoints.go b/clients/lor/endpoints.go index 12dccf7..32da564 100644 --- a/clients/lor/endpoints.go +++ b/clients/lor/endpoints.go @@ -17,7 +17,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) // # Riot API Reference @@ -46,10 +45,10 @@ type DeckV1 struct { // [lor-deck-v1.getDecks]: https://developer.riotgames.com/api-methods/#lor-deck-v1/GET_getDecks func (e *DeckV1) Decks(ctx context.Context, route api.RegionalRoute, authorization string) ([]DeckV1DTO, error) { logger := e.internal.Logger("LOR_DeckV1_Decks") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lor/deck/v1/decks/me", "lor-deck-v1.getDecks", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]DeckV1DTO), err } if authorization == "" { @@ -59,10 +58,10 @@ func (e *DeckV1) Decks(ctx context.Context, route api.RegionalRoute, authorizati var data []DeckV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]DeckV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -81,10 +80,10 @@ func (e *DeckV1) Decks(ctx context.Context, route api.RegionalRoute, authorizati // [lor-deck-v1.createDeck]: https://developer.riotgames.com/api-methods/#lor-deck-v1/POST_createDeck func (e *DeckV1) CreateDeck(ctx context.Context, route api.RegionalRoute, body *NewDeckV1DTO, authorization string) (string, error) { logger := e.internal.Logger("LOR_DeckV1_CreateDeck") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodPost, route, "/lor/deck/v1/decks/me", "lor-deck-v1.createDeck", body) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new(string), err } if authorization == "" { @@ -94,10 +93,10 @@ func (e *DeckV1) CreateDeck(ctx context.Context, route api.RegionalRoute, body * var data string err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new(string), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -127,10 +126,10 @@ type InventoryV1 struct { // [lor-inventory-v1.getCards]: https://developer.riotgames.com/api-methods/#lor-inventory-v1/GET_getCards func (e *InventoryV1) Cards(ctx context.Context, route api.RegionalRoute, authorization string) ([]CardV1DTO, error) { logger := e.internal.Logger("LOR_InventoryV1_Cards") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lor/inventory/v1/cards/me", "lor-inventory-v1.getCards", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]CardV1DTO), err } if authorization == "" { @@ -140,10 +139,10 @@ func (e *InventoryV1) Cards(ctx context.Context, route api.RegionalRoute, author var data []CardV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]CardV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -173,19 +172,19 @@ type MatchV1 struct { // [lor-match-v1.getMatchIdsByPUUID]: https://developer.riotgames.com/api-methods/#lor-match-v1/GET_getMatchIdsByPUUID func (e *MatchV1) ListByPUUID(ctx context.Context, route api.RegionalRoute, puuid string) ([]string, error) { logger := e.internal.Logger("LOR_MatchV1_ListByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lor/match/v1/matches/by-puuid/%v/ids", puuid), "lor-match-v1.getMatchIdsByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]string), err } var data []string err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]string), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -204,19 +203,19 @@ func (e *MatchV1) ListByPUUID(ctx context.Context, route api.RegionalRoute, puui // [lor-match-v1.getMatch]: https://developer.riotgames.com/api-methods/#lor-match-v1/GET_getMatch func (e *MatchV1) ByID(ctx context.Context, route api.RegionalRoute, matchId string) (*MatchV1DTO, error) { logger := e.internal.Logger("LOR_MatchV1_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/lor/match/v1/matches/%v", matchId), "lor-match-v1.getMatch", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data MatchV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -245,19 +244,19 @@ type RankedV1 struct { // [lor-ranked-v1.getLeaderboards]: https://developer.riotgames.com/api-methods/#lor-ranked-v1/GET_getLeaderboards func (e *RankedV1) Leaderboards(ctx context.Context, route api.RegionalRoute) (*LeaderboardV1DTO, error) { logger := e.internal.Logger("LOR_RankedV1_Leaderboards") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lor/ranked/v1/leaderboards", "lor-ranked-v1.getLeaderboards", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data LeaderboardV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -286,18 +285,18 @@ type StatusV1 struct { // [lor-status-v1.getPlatformData]: https://developer.riotgames.com/api-methods/#lor-status-v1/GET_getPlatformData func (e *StatusV1) Platform(ctx context.Context, route api.RegionalRoute) (*PlatformDataV1DTO, error) { logger := e.internal.Logger("LOR_StatusV1_Platform") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/lor/status/v1/platform-data", "lor-status-v1.getPlatformData", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data PlatformDataV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } diff --git a/clients/riot/endpoints.go b/clients/riot/endpoints.go index cbbe2d1..dff2961 100644 --- a/clients/riot/endpoints.go +++ b/clients/riot/endpoints.go @@ -17,7 +17,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) // # Riot API Reference @@ -46,19 +45,19 @@ type AccountV1 struct { // [account-v1.getByPuuid]: https://developer.riotgames.com/api-methods/#account-v1/GET_getByPuuid func (e *AccountV1) ByPUUID(ctx context.Context, route api.RegionalRoute, puuid string) (*AccountV1DTO, error) { logger := e.internal.Logger("Riot_AccountV1_ByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/riot/account/v1/accounts/by-puuid/%v", puuid), "account-v1.getByPuuid", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data AccountV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -78,19 +77,19 @@ func (e *AccountV1) ByPUUID(ctx context.Context, route api.RegionalRoute, puuid // [account-v1.getByRiotId]: https://developer.riotgames.com/api-methods/#account-v1/GET_getByRiotId func (e *AccountV1) ByRiotID(ctx context.Context, route api.RegionalRoute, gameName string, tagLine string) (*AccountV1DTO, error) { logger := e.internal.Logger("Riot_AccountV1_ByRiotID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/riot/account/v1/accounts/by-riot-id/%v/%v", gameName, tagLine), "account-v1.getByRiotId", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data AccountV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -109,10 +108,10 @@ func (e *AccountV1) ByRiotID(ctx context.Context, route api.RegionalRoute, gameN // [account-v1.getByAccessToken]: https://developer.riotgames.com/api-methods/#account-v1/GET_getByAccessToken func (e *AccountV1) ByAccessToken(ctx context.Context, route api.RegionalRoute, authorization string) (*AccountV1DTO, error) { logger := e.internal.Logger("Riot_AccountV1_ByAccessToken") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/riot/account/v1/accounts/me", "account-v1.getByAccessToken", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } if authorization == "" { @@ -122,10 +121,10 @@ func (e *AccountV1) ByAccessToken(ctx context.Context, route api.RegionalRoute, var data AccountV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -145,18 +144,18 @@ func (e *AccountV1) ByAccessToken(ctx context.Context, route api.RegionalRoute, // [account-v1.getActiveShard]: https://developer.riotgames.com/api-methods/#account-v1/GET_getActiveShard func (e *AccountV1) ActiveShard(ctx context.Context, route api.RegionalRoute, game string, puuid string) (*ActiveShardV1DTO, error) { logger := e.internal.Logger("Riot_AccountV1_ActiveShard") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/riot/account/v1/active-shards/by-game/%v/by-puuid/%v", game, puuid), "account-v1.getActiveShard", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data ActiveShardV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } diff --git a/clients/tft/endpoints.go b/clients/tft/endpoints.go index 29ff16e..2d5390a 100644 --- a/clients/tft/endpoints.go +++ b/clients/tft/endpoints.go @@ -17,7 +17,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) // # Riot API Reference @@ -46,10 +45,10 @@ type LeagueV1 struct { // [tft-league-v1.getChallengerLeague]: https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getChallengerLeague func (e *LeagueV1) ChallengerByQueue(ctx context.Context, route PlatformRoute, queue string) (*LeagueListV1DTO, error) { logger := e.internal.Logger("TFT_LeagueV1_ChallengerByQueue") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/tft/league/v1/challenger", "tft-league-v1.getChallengerLeague", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } values := equinoxReq.Request.URL.Query() @@ -60,10 +59,10 @@ func (e *LeagueV1) ChallengerByQueue(ctx context.Context, route PlatformRoute, q var data LeagueListV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -82,19 +81,19 @@ func (e *LeagueV1) ChallengerByQueue(ctx context.Context, route PlatformRoute, q // [tft-league-v1.getLeagueEntriesForSummoner]: https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getLeagueEntriesForSummoner func (e *LeagueV1) SummonerEntries(ctx context.Context, route PlatformRoute, summonerId string) ([]LeagueEntryV1DTO, error) { logger := e.internal.Logger("TFT_LeagueV1_SummonerEntries") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/league/v1/entries/by-summoner/%v", summonerId), "tft-league-v1.getLeagueEntriesForSummoner", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]LeagueEntryV1DTO), err } var data []LeagueEntryV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]LeagueEntryV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -116,10 +115,10 @@ func (e *LeagueV1) SummonerEntries(ctx context.Context, route PlatformRoute, sum // [tft-league-v1.getLeagueEntries]: https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getLeagueEntries func (e *LeagueV1) Entries(ctx context.Context, route PlatformRoute, tier Tier, division string, queue string, page int32) ([]LeagueEntryV1DTO, error) { logger := e.internal.Logger("TFT_LeagueV1_Entries") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/league/v1/entries/%v/%v", tier, division), "tft-league-v1.getLeagueEntries", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]LeagueEntryV1DTO), err } values := equinoxReq.Request.URL.Query() @@ -133,10 +132,10 @@ func (e *LeagueV1) Entries(ctx context.Context, route PlatformRoute, tier Tier, var data []LeagueEntryV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]LeagueEntryV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -155,10 +154,10 @@ func (e *LeagueV1) Entries(ctx context.Context, route PlatformRoute, tier Tier, // [tft-league-v1.getGrandmasterLeague]: https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getGrandmasterLeague func (e *LeagueV1) GrandmasterByQueue(ctx context.Context, route PlatformRoute, queue string) (*LeagueListV1DTO, error) { logger := e.internal.Logger("TFT_LeagueV1_GrandmasterByQueue") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/tft/league/v1/grandmaster", "tft-league-v1.getGrandmasterLeague", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } values := equinoxReq.Request.URL.Query() @@ -169,10 +168,10 @@ func (e *LeagueV1) GrandmasterByQueue(ctx context.Context, route PlatformRoute, var data LeagueListV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -191,19 +190,19 @@ func (e *LeagueV1) GrandmasterByQueue(ctx context.Context, route PlatformRoute, // [tft-league-v1.getLeagueById]: https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getLeagueById func (e *LeagueV1) ByID(ctx context.Context, route PlatformRoute, leagueId string) (*LeagueListV1DTO, error) { logger := e.internal.Logger("TFT_LeagueV1_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/league/v1/leagues/%v", leagueId), "tft-league-v1.getLeagueById", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data LeagueListV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -222,10 +221,10 @@ func (e *LeagueV1) ByID(ctx context.Context, route PlatformRoute, leagueId strin // [tft-league-v1.getMasterLeague]: https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getMasterLeague func (e *LeagueV1) MasterByQueue(ctx context.Context, route PlatformRoute, queue string) (*LeagueListV1DTO, error) { logger := e.internal.Logger("TFT_LeagueV1_MasterByQueue") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/tft/league/v1/master", "tft-league-v1.getMasterLeague", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } values := equinoxReq.Request.URL.Query() @@ -236,10 +235,10 @@ func (e *LeagueV1) MasterByQueue(ctx context.Context, route PlatformRoute, queue var data LeagueListV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -258,19 +257,19 @@ func (e *LeagueV1) MasterByQueue(ctx context.Context, route PlatformRoute, queue // [tft-league-v1.getTopRatedLadder]: https://developer.riotgames.com/api-methods/#tft-league-v1/GET_getTopRatedLadder func (e *LeagueV1) TopRatedLadder(ctx context.Context, route PlatformRoute, queue QueueType) ([]TopRatedLadderEntryV1DTO, error) { logger := e.internal.Logger("TFT_LeagueV1_TopRatedLadder") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/league/v1/rated-ladders/%v/top", queue), "tft-league-v1.getTopRatedLadder", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]TopRatedLadderEntryV1DTO), err } var data []TopRatedLadderEntryV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]TopRatedLadderEntryV1DTO), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -304,10 +303,10 @@ type MatchV1 struct { // [tft-match-v1.getMatchIdsByPUUID]: https://developer.riotgames.com/api-methods/#tft-match-v1/GET_getMatchIdsByPUUID func (e *MatchV1) ListByPUUID(ctx context.Context, route api.RegionalRoute, puuid string, start int32, endTime int64, startTime int64, count int32) ([]string, error) { logger := e.internal.Logger("TFT_MatchV1_ListByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/match/v1/matches/by-puuid/%v/ids", puuid), "tft-match-v1.getMatchIdsByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return *new([]string), err } values := equinoxReq.Request.URL.Query() @@ -327,10 +326,10 @@ func (e *MatchV1) ListByPUUID(ctx context.Context, route api.RegionalRoute, puui var data []string err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return *new([]string), err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return data, nil } @@ -349,19 +348,19 @@ func (e *MatchV1) ListByPUUID(ctx context.Context, route api.RegionalRoute, puui // [tft-match-v1.getMatch]: https://developer.riotgames.com/api-methods/#tft-match-v1/GET_getMatch func (e *MatchV1) ByID(ctx context.Context, route api.RegionalRoute, matchId string) (*MatchV1DTO, error) { logger := e.internal.Logger("TFT_MatchV1_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/match/v1/matches/%v", matchId), "tft-match-v1.getMatch", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data MatchV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -390,19 +389,19 @@ type StatusV1 struct { // [tft-status-v1.getPlatformData]: https://developer.riotgames.com/api-methods/#tft-status-v1/GET_getPlatformData func (e *StatusV1) Platform(ctx context.Context, route PlatformRoute) (*PlatformDataV1DTO, error) { logger := e.internal.Logger("TFT_StatusV1_Platform") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/tft/status/v1/platform-data", "tft-status-v1.getPlatformData", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data PlatformDataV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -432,19 +431,19 @@ type SummonerV1 struct { // [tft-summoner-v1.getByAccountId]: https://developer.riotgames.com/api-methods/#tft-summoner-v1/GET_getByAccountId func (e *SummonerV1) ByAccountID(ctx context.Context, route PlatformRoute, encryptedAccountId string) (*SummonerV1DTO, error) { logger := e.internal.Logger("TFT_SummonerV1_ByAccountID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/summoner/v1/summoners/by-account/%v", encryptedAccountId), "tft-summoner-v1.getByAccountId", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -463,19 +462,19 @@ func (e *SummonerV1) ByAccountID(ctx context.Context, route PlatformRoute, encry // [tft-summoner-v1.getBySummonerName]: https://developer.riotgames.com/api-methods/#tft-summoner-v1/GET_getBySummonerName func (e *SummonerV1) ByName(ctx context.Context, route PlatformRoute, summonerName string) (*SummonerV1DTO, error) { logger := e.internal.Logger("TFT_SummonerV1_ByName") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/summoner/v1/summoners/by-name/%v", summonerName), "tft-summoner-v1.getBySummonerName", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -494,19 +493,19 @@ func (e *SummonerV1) ByName(ctx context.Context, route PlatformRoute, summonerNa // [tft-summoner-v1.getByPUUID]: https://developer.riotgames.com/api-methods/#tft-summoner-v1/GET_getByPUUID func (e *SummonerV1) ByPUUID(ctx context.Context, route PlatformRoute, encryptedPUUID string) (*SummonerV1DTO, error) { logger := e.internal.Logger("TFT_SummonerV1_ByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/summoner/v1/summoners/by-puuid/%v", encryptedPUUID), "tft-summoner-v1.getByPUUID", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -525,10 +524,10 @@ func (e *SummonerV1) ByPUUID(ctx context.Context, route PlatformRoute, encrypted // [tft-summoner-v1.getByAccessToken]: https://developer.riotgames.com/api-methods/#tft-summoner-v1/GET_getByAccessToken func (e *SummonerV1) ByAccessToken(ctx context.Context, route PlatformRoute, authorization string) (*SummonerV1DTO, error) { logger := e.internal.Logger("TFT_SummonerV1_ByAccessToken") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/tft/summoner/v1/summoners/me", "tft-summoner-v1.getByAccessToken", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } if authorization == "" { @@ -538,10 +537,10 @@ func (e *SummonerV1) ByAccessToken(ctx context.Context, route PlatformRoute, aut var data SummonerV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -560,18 +559,18 @@ func (e *SummonerV1) ByAccessToken(ctx context.Context, route PlatformRoute, aut // [tft-summoner-v1.getBySummonerId]: https://developer.riotgames.com/api-methods/#tft-summoner-v1/GET_getBySummonerId func (e *SummonerV1) BySummonerID(ctx context.Context, route PlatformRoute, encryptedSummonerId string) (*SummonerV1DTO, error) { logger := e.internal.Logger("TFT_SummonerV1_BySummonerID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/tft/summoner/v1/summoners/%v", encryptedSummonerId), "tft-summoner-v1.getBySummonerId", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data SummonerV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } diff --git a/clients/val/endpoints.go b/clients/val/endpoints.go index 35f88a3..252e340 100644 --- a/clients/val/endpoints.go +++ b/clients/val/endpoints.go @@ -17,7 +17,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) // # Riot API Reference @@ -46,10 +45,10 @@ type ContentV1 struct { // [val-content-v1.getContent]: https://developer.riotgames.com/api-methods/#val-content-v1/GET_getContent func (e *ContentV1) Content(ctx context.Context, route PlatformRoute, locale string) (*ContentV1DTO, error) { logger := e.internal.Logger("VAL_ContentV1_Content") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/val/content/v1/contents", "val-content-v1.getContent", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } values := equinoxReq.Request.URL.Query() @@ -60,10 +59,10 @@ func (e *ContentV1) Content(ctx context.Context, route PlatformRoute, locale str var data ContentV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -93,19 +92,19 @@ type MatchV1 struct { // [val-match-v1.getMatch]: https://developer.riotgames.com/api-methods/#val-match-v1/GET_getMatch func (e *MatchV1) ByID(ctx context.Context, route PlatformRoute, matchId string) (*MatchV1DTO, error) { logger := e.internal.Logger("VAL_MatchV1_ByID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/val/match/v1/matches/%v", matchId), "val-match-v1.getMatch", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data MatchV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -124,19 +123,19 @@ func (e *MatchV1) ByID(ctx context.Context, route PlatformRoute, matchId string) // [val-match-v1.getMatchlist]: https://developer.riotgames.com/api-methods/#val-match-v1/GET_getMatchlist func (e *MatchV1) ListByPUUID(ctx context.Context, route PlatformRoute, puuid string) (*MatchlistV1DTO, error) { logger := e.internal.Logger("VAL_MatchV1_ListByPUUID") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/val/match/v1/matchlists/by-puuid/%v", puuid), "val-match-v1.getMatchlist", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data MatchlistV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -159,19 +158,19 @@ func (e *MatchV1) ListByPUUID(ctx context.Context, route PlatformRoute, puuid st // [val-match-v1.getRecent]: https://developer.riotgames.com/api-methods/#val-match-v1/GET_getRecent func (e *MatchV1) Recent(ctx context.Context, route PlatformRoute, queue string) (*RecentMatchesV1DTO, error) { logger := e.internal.Logger("VAL_MatchV1_Recent") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/val/match/v1/recent-matches/by-queue/%v", queue), "val-match-v1.getRecent", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data RecentMatchesV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -203,10 +202,10 @@ type RankedV1 struct { // [val-ranked-v1.getLeaderboard]: https://developer.riotgames.com/api-methods/#val-ranked-v1/GET_getLeaderboard func (e *RankedV1) Leaderboard(ctx context.Context, route PlatformRoute, actId string, size int32, startIndex int32) (*LeaderboardV1DTO, error) { logger := e.internal.Logger("VAL_RankedV1_Leaderboard") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, fmt.Sprintf("/val/ranked/v1/leaderboards/by-act/%v", actId), "val-ranked-v1.getLeaderboard", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } values := equinoxReq.Request.URL.Query() @@ -220,10 +219,10 @@ func (e *RankedV1) Leaderboard(ctx context.Context, route PlatformRoute, actId s var data LeaderboardV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } @@ -252,18 +251,18 @@ type StatusV1 struct { // [val-status-v1.getPlatformData]: https://developer.riotgames.com/api-methods/#val-status-v1/GET_getPlatformData func (e *StatusV1) Platform(ctx context.Context, route PlatformRoute) (*PlatformDataV1DTO, error) { logger := e.internal.Logger("VAL_StatusV1_Platform") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.MethodGet, route, "/val/status/v1/platform-data", "val-status-v1.getPlatformData", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data PlatformDataV1DTO err = e.internal.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return &data, nil } diff --git a/equinox.go b/equinox.go index d16436a..c691627 100644 --- a/equinox.go +++ b/equinox.go @@ -16,6 +16,7 @@ import ( "github.com/Kyagara/equinox/clients/val" "github.com/Kyagara/equinox/internal" "github.com/allegro/bigcache/v3" + "github.com/rs/zerolog" ) type Equinox struct { @@ -62,7 +63,7 @@ func NewClientWithConfig(config *api.EquinoxConfig) (*Equinox, error) { // Returns the default Equinox config with a provided key. // -// - `LogLevel` : api.WARN_LOG_LEVEL +// - `LogLevel` : zerolog.WarnLevel // - `HTTPClient` : http.Client with timeout of 15 seconds // - `Retry` : Retry on 429 1 time // - `Cache` : BigCache with TTL of 4 minutes @@ -74,7 +75,7 @@ func DefaultConfig(key string) (*api.EquinoxConfig, error) { } config := &api.EquinoxConfig{ Key: key, - LogLevel: api.WARN_LOG_LEVEL, + LogLevel: zerolog.WarnLevel, HTTPClient: &http.Client{ Timeout: 15 * time.Second, }, diff --git a/equinox_test.go b/equinox_test.go index 5ae2c5f..50e3cf9 100644 --- a/equinox_test.go +++ b/equinox_test.go @@ -12,6 +12,7 @@ import ( "github.com/Kyagara/equinox/ratelimit" "github.com/Kyagara/equinox/test/util" "github.com/h2non/gock" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) @@ -112,7 +113,7 @@ func TestRateLimitWithMock(t *testing.T) { } config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) diff --git a/go.mod b/go.mod index 5c0810e..2659bbd 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0 github.com/h2non/gock v1.2.0 github.com/redis/go-redis/v9 v9.3.0 + github.com/rs/zerolog v1.31.0 github.com/stretchr/testify v1.8.4 - go.uber.org/zap v1.26.0 ) require ( @@ -19,9 +19,11 @@ require ( github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect github.com/kr/pretty v0.3.1 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/yuin/gopher-lua v1.1.0 // indirect - go.uber.org/multierr v1.11.0 // indirect + golang.org/x/sys v0.15.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index f4aa672..e355d73 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,7 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -22,6 +23,7 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0 h1:ymLjT4f35nQbASLnvxEde4XOBL+Sn7rFuV+FOJqkljg= github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0/go.mod h1:6daplAwHHGbUGib4990V3Il26O0OC4aRyvewaaAihaA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE= github.com/h2non/gock v1.2.0/go.mod h1:tNhoxHYW2W42cYkYb1WqzdbYIieALC99kpYr7rH/BQk= @@ -34,26 +36,35 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/redis/go-redis/v9 v9.3.0 h1:RiVDjmig62jIWp7Kk4XVLs0hzV6pI3PyTnnL0cnn0u0= github.com/redis/go-redis/v9 v9.3.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/internal/client.go b/internal/client.go index 6ef6401..3ac2f00 100644 --- a/internal/client.go +++ b/internal/client.go @@ -13,11 +13,11 @@ import ( "time" jsonv2 "github.com/go-json-experiment/json" + "github.com/rs/zerolog" "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/cache" "github.com/Kyagara/equinox/ratelimit" - "go.uber.org/zap" ) type InternalClient struct { @@ -52,12 +52,9 @@ func NewInternalClient(config *api.EquinoxConfig) (*InternalClient, error) { if config == nil { return nil, fmt.Errorf("equinox configuration not provided") } - logger, err := NewLogger(config) - if err != nil { - return nil, err - } + logger := NewLogger(config) if config.Key == "" { - logger.Warn("API key was not provided, requests using other clients will result in errors.") + logger.Warn().Msg("API key was not provided, requests using other clients will result in errors.") } if config.Cache == nil { config.Cache = &cache.Cache{TTL: 0} @@ -70,7 +67,7 @@ func NewInternalClient(config *api.EquinoxConfig) (*InternalClient, error) { http: config.HTTPClient, loggers: &Loggers{ main: logger, - methods: make(map[string]*zap.Logger), + methods: make(map[string]zerolog.Logger), mutex: sync.Mutex{}, }, cache: config.Cache, @@ -83,7 +80,7 @@ func NewInternalClient(config *api.EquinoxConfig) (*InternalClient, error) { } // Creates a request to the provided route and URL. -func (c *InternalClient) Request(ctx context.Context, logger *zap.Logger, baseURL string, httpMethod string, route any, path string, methodID string, body any) (*api.EquinoxRequest, error) { +func (c *InternalClient) Request(ctx context.Context, logger zerolog.Logger, baseURL string, httpMethod string, route any, path string, methodID string, body any) (*api.EquinoxRequest, error) { if ctx == nil { return nil, errContextIsNil } @@ -140,9 +137,9 @@ func (c *InternalClient) Execute(ctx context.Context, equinoxReq *api.EquinoxReq if c.isCacheEnabled && equinoxReq.Method == http.MethodGet { if item, err := c.cache.Get(url); err != nil { - equinoxReq.Logger.Error("Error retrieving cached response", zap.Error(err)) + equinoxReq.Logger.Error().Err(err).Msg("Error retrieving cached response") } else if item != nil { - equinoxReq.Logger.Debug("Cache hit") + equinoxReq.Logger.Debug().Msg("Cache hit") return jsonv2.Unmarshal(item, &target) } } @@ -155,7 +152,7 @@ func (c *InternalClient) Execute(ctx context.Context, equinoxReq *api.EquinoxReq } } - equinoxReq.Logger.Info("Sending request") + equinoxReq.Logger.Info().Msg("Sending request") response, err := c.http.Do(equinoxReq.Request) if err != nil { return err @@ -164,7 +161,7 @@ func (c *InternalClient) Execute(ctx context.Context, equinoxReq *api.EquinoxReq delay, err := c.checkResponse(equinoxReq, response) if err != nil { - equinoxReq.Logger.Error("Request failed", zap.Error(err)) + equinoxReq.Logger.Error().Err(err).Msg("Request failed") return err } @@ -173,7 +170,7 @@ func (c *InternalClient) Execute(ctx context.Context, equinoxReq *api.EquinoxReq if ok && deadline.Before(time.Now().Add(delay)) { return ratelimit.ErrContextDeadlineExceeded } - equinoxReq.Logger.Info("Retrying request after sleep", zap.Duration("sleep", delay)) + equinoxReq.Logger.Info().Dur("sleep", delay).Msg("Retrying request after sleep") select { case <-time.After(delay): equinoxReq.Retries++ @@ -183,7 +180,7 @@ func (c *InternalClient) Execute(ctx context.Context, equinoxReq *api.EquinoxReq } } - equinoxReq.Logger.Info("Request successful") + equinoxReq.Logger.Info().Msg("Request successful") body, err := io.ReadAll(response.Body) if err != nil { return err @@ -191,9 +188,9 @@ func (c *InternalClient) Execute(ctx context.Context, equinoxReq *api.EquinoxReq if c.isCacheEnabled && equinoxReq.Method == http.MethodGet { if err := c.cache.Set(url, body); err != nil { - equinoxReq.Logger.Error("Error caching item", zap.Error(err)) + equinoxReq.Logger.Error().Err(err).Msg("Error caching item") } else { - equinoxReq.Logger.Debug("Cache set") + equinoxReq.Logger.Debug().Msg("Cache set") } } return jsonv2.Unmarshal(body, &target) @@ -209,7 +206,7 @@ func (c *InternalClient) checkResponse(equinoxReq *api.EquinoxRequest, response } if response.StatusCode < http.StatusOK || response.StatusCode > 299 { - equinoxReq.Logger.Error("Response with error code", zap.String("code", response.Status)) + equinoxReq.Logger.Error().Str("code", response.Status).Msg("Response with error code") err, ok := api.StatusCodeToError[response.StatusCode] if !ok { return 0, api.ErrorResponse{ @@ -234,16 +231,16 @@ func getAuthorizationHeaderHash(key string) string { func (c *InternalClient) GetDDragonLOLVersions(ctx context.Context, id string) ([]string, error) { logger := c.Logger(id) - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := c.Request(ctx, logger, api.D_DRAGON_BASE_URL_FORMAT, http.MethodGet, "", "/api/versions.json", "", nil) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return nil, err } var data []string err = c.Execute(ctx, equinoxReq, &data) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return nil, err } return data, nil diff --git a/internal/logger.go b/internal/logger.go index 0323fe5..89e1f34 100644 --- a/internal/logger.go +++ b/internal/logger.go @@ -1,48 +1,44 @@ package internal import ( - "fmt" + "os" "strings" "sync" "github.com/Kyagara/equinox/api" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" + "github.com/rs/zerolog" ) type Loggers struct { - main *zap.Logger - methods map[string]*zap.Logger + main zerolog.Logger + methods map[string]zerolog.Logger mutex sync.Mutex } -// Creates a new zap.Logger from the configuration parameters provided. -func NewLogger(config *api.EquinoxConfig) (*zap.Logger, error) { +func NewLogger(config *api.EquinoxConfig) zerolog.Logger { + zerolog.TimeFieldFormat = zerolog.TimeFormatUnix if config == nil { - return nil, fmt.Errorf("error initializing logger, equinox configuration not provided") + return zerolog.Nop() } - var zapConfig zap.Config switch config.LogLevel { - case api.NOP_LOG_LEVEL: - return zap.NewNop(), nil - case api.DEBUG_LOG_LEVEL: - zapConfig = zap.NewDevelopmentConfig() + case zerolog.Disabled: + return zerolog.Nop() + case zerolog.DebugLevel: + return zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Object("equinox", config).Timestamp().Logger() default: - zapConfig = zap.NewProductionConfig() - zapConfig.Level = zap.NewAtomicLevelAt(zapcore.Level(config.LogLevel)) + return zerolog.New(os.Stderr).Level(config.LogLevel).With().Object("equinox", config).Timestamp().Logger() } - return zapConfig.Build(zap.Fields(zap.Object("equinox", config))) } // Used to access the internal logger, this is used to log events from other clients (RiotClient, LOLClient...). -func (c *InternalClient) Logger(id string) *zap.Logger { +func (c *InternalClient) Logger(id string) zerolog.Logger { c.loggers.mutex.Lock() defer c.loggers.mutex.Unlock() if logger, ok := c.loggers.methods[id]; ok { return logger } names := strings.Split(id, "_") - logger := c.loggers.main.With(zap.String("client", names[0]), zap.String("endpoint", names[1]), zap.String("method", names[2])) + logger := c.loggers.main.With().Str("client", names[0]).Str("endpoint", names[1]).Str("method", names[2]).Logger() c.loggers.methods[id] = logger return logger } diff --git a/internal/logger_test.go b/internal/logger_test.go index fea53a7..0f367ee 100644 --- a/internal/logger_test.go +++ b/internal/logger_test.go @@ -9,32 +9,26 @@ import ( "github.com/Kyagara/equinox/cache" "github.com/Kyagara/equinox/internal" "github.com/Kyagara/equinox/test/util" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" - "go.uber.org/zap/zapcore" ) func TestNewLogger(t *testing.T) { - _, err := internal.NewLogger(nil) - require.NotEmpty(t, err, "expecting non-nil error") - config := &api.EquinoxConfig{ - LogLevel: api.NOP_LOG_LEVEL, Cache: &cache.Cache{TTL: 60 * time.Second}, + LogLevel: zerolog.Disabled, Cache: &cache.Cache{TTL: 60 * time.Second}, HTTPClient: &http.Client{Timeout: 15 * time.Second}, } - logger, err := internal.NewLogger(config) - require.Nil(t, err, "expecting nil error") + logger := internal.NewLogger(config) require.NotEmpty(t, logger, "expecting non-nil logger") - config.LogLevel = api.DEBUG_LOG_LEVEL - logger, err = internal.NewLogger(config) - require.Nil(t, err, "expecting nil error") - require.Equal(t, logger.Core().Enabled(zapcore.DebugLevel), true, "expecting logger to be enabled for Debug level") + config.LogLevel = zerolog.DebugLevel + logger = internal.NewLogger(config) + require.Equal(t, logger.Debug().Enabled(), true, "expecting logger to be enabled for Debug level") - config.LogLevel = api.INFO_LOG_LEVEL - logger, err = internal.NewLogger(config) - require.Nil(t, err, "expecting nil error") - require.Equal(t, logger.Core().Enabled(zapcore.InfoLevel), true, "expecting logger to be enabled for Debug level") + config.LogLevel = zerolog.InfoLevel + logger = internal.NewLogger(config) + require.Equal(t, logger.Info().Enabled(), true, "expecting logger to be enabled for Debug level") } func TestLogger(t *testing.T) { @@ -45,8 +39,8 @@ func TestLogger(t *testing.T) { require.NotEmpty(t, logger, "expecting non-nil Logger") logger = internal.Logger("client_endpoint_method") require.NotEmpty(t, logger, "expecting non-nil Logger") - logger.Debug("Debug log") - logger.Info("Info log") - logger.Warn("Warn log") - logger.Error("Error log") + logger.Debug().Msg("Debug log") + logger.Info().Msg("Info log") + logger.Warn().Msg("Warn log") + logger.Error().Msg("Error log") } diff --git a/ratelimit/bucket.go b/ratelimit/bucket.go index bf84126..62815e8 100644 --- a/ratelimit/bucket.go +++ b/ratelimit/bucket.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "go.uber.org/zap/zapcore" + "github.com/rs/zerolog" ) type Bucket struct { @@ -20,10 +20,8 @@ type Bucket struct { mutex sync.Mutex } -func (b *Bucket) MarshalLogObject(encoder zapcore.ObjectEncoder) error { - encoder.AddDuration("interval", b.interval) - encoder.AddInt("limit", b.limit) - return nil +func (b *Bucket) MarshalZerologObject(encoder *zerolog.Event) { + encoder.Int("tokens", b.tokens).Int("limit", b.limit).Dur("interval", b.interval).Time("next", b.next) } func NewBucket(interval time.Duration, limit int, tokens int) *Bucket { diff --git a/ratelimit/limit.go b/ratelimit/limit.go index b69786a..f4e93e1 100644 --- a/ratelimit/limit.go +++ b/ratelimit/limit.go @@ -7,7 +7,6 @@ import ( "time" "github.com/Kyagara/equinox/api" - "go.uber.org/zap" ) // Limit represents a collection of buckets and the type of limit (application or method). @@ -48,7 +47,7 @@ func (l *Limit) checkBuckets(ctx context.Context, equinoxReq *api.EquinoxRequest } } for i := len(limited) - 1; i >= 0; i-- { - equinoxReq.Logger.Warn("Rate limited", zap.Any("route", equinoxReq.Route), zap.String("method_id", equinoxReq.MethodID), zap.String("limit_type", string(l.limitType))) + equinoxReq.Logger.Warn().Any("route", equinoxReq.Route).Str("method_id", equinoxReq.MethodID).Str("limit_type", l.limitType).Object("bucket", limited[i]).Msg("Rate limited") err := limited[i].wait(ctx) if err != nil { select { diff --git a/ratelimit/ratelimit.go b/ratelimit/ratelimit.go index 6165e68..e56f08d 100644 --- a/ratelimit/ratelimit.go +++ b/ratelimit/ratelimit.go @@ -10,7 +10,6 @@ import ( "time" "github.com/Kyagara/equinox/api" - "go.uber.org/zap" ) const ( @@ -82,11 +81,11 @@ func (r *RateLimit) Update(equinoxReq *api.EquinoxRequest, headers *http.Header) limits := r.Region[equinoxReq.Route] if limits.App.limitsDontMatch(headers.Get(APP_RATE_LIMIT_HEADER)) { limits.App = parseHeaders(headers.Get(APP_RATE_LIMIT_HEADER), headers.Get(APP_RATE_LIMIT_COUNT_HEADER), APP_RATE_LIMIT_TYPE) - equinoxReq.Logger.Debug("New Application buckets", zap.Objects("buckets", limits.App.buckets)) + equinoxReq.Logger.Debug().Msg("New Application buckets") } if limits.Methods[equinoxReq.MethodID].limitsDontMatch(headers.Get(METHOD_RATE_LIMIT_HEADER)) { limits.Methods[equinoxReq.MethodID] = parseHeaders(headers.Get(METHOD_RATE_LIMIT_HEADER), headers.Get(METHOD_RATE_LIMIT_COUNT_HEADER), METHOD_RATE_LIMIT_TYPE) - equinoxReq.Logger.Debug("New Method buckets", zap.Objects("buckets", limits.Methods[equinoxReq.MethodID].buckets)) + equinoxReq.Logger.Debug().Msg("New Method buckets") } } diff --git a/srcgen/templates/api/constants.go.dt b/srcgen/templates/api/constants.go.dt index ae8a1ca..bdab438 100644 --- a/srcgen/templates/api/constants.go.dt +++ b/srcgen/templates/api/constants.go.dt @@ -8,12 +8,12 @@ import ( "net/http" - "go.uber.org/zap" + "github.com/rs/zerolog" ) // EquinoxRequest represents a request to the Riot API and CDNs, its a struct that contains all information about a request. type EquinoxRequest struct { - Logger *zap.Logger + Logger zerolog.Logger MethodID string Route any BaseURL string @@ -32,21 +32,6 @@ const ( C_DRAGON_BASE_URL_FORMAT = "https://cdn.communitydragon.org%s" ) -type LogLevel int8 - -const ( - // NOP_LOG_LEVEL won't log anything, this is the default behaviour for the Default client. - NOP_LOG_LEVEL LogLevel = iota - 2 - // DEBUG_LOG_LEVEL will log everything. - DEBUG_LOG_LEVEL - // INFO_LOG_LEVEL will log the requests being made and if they were successful. - INFO_LOG_LEVEL - // WARN_LOG_LEVEL will log when a request was rate limited. - WARN_LOG_LEVEL - // ERROR_LOG_LEVEL will log every error. - ERROR_LOG_LEVEL -) - // Regional routes, used in tournament services, Legends of Runeterra (LoR), and some other endpoints. type RegionalRoute string diff --git a/srcgen/templates/clients/endpoints.go.dt b/srcgen/templates/clients/endpoints.go.dt index 7db5058..5a8d5e7 100644 --- a/srcgen/templates/clients/endpoints.go.dt +++ b/srcgen/templates/clients/endpoints.go.dt @@ -13,7 +13,6 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/internal" - "go.uber.org/zap" ) {{ @@ -141,10 +140,10 @@ type {{= normalizedStructName }} struct { // [{{= operationId }}]: {{= operation.externalDocs.url }} func (e *{{= normalizedStructName }}) {{= method }}({{= argBuilder.join(', ') }}) {{= !hasReturn ? "error" : `(${isPrimitiveType ? "" : "*"}${returnValue}, error)` }} { logger := e.internal.Logger("{{= clientNormalizedName + "_" + normalizedStructName + "_" + method }}") - logger.Debug("Method started execution") + logger.Debug().Msg("Method started execution") equinoxReq, err := e.internal.Request(ctx, logger, api.RIOT_API_BASE_URL_FORMAT, http.Method{{= dotUtils.capitalize(verb) }}, route, {{= routeArgument }}, "{{= operationId }}", {{? bodyType }}body{{?? true }}nil{{?}}) if err != nil { - logger.Error("Error creating request", zap.Error(err)) + logger.Error().Err(err).Msg("Error creating request") return {{? hasReturn }}{{= isPrimitiveType ? `*new(${returnValue})` : "nil" }}, err{{?? true }}{{= isPrimitiveType ? `*new(${returnValue})` : "nil" }}{{?}} } {{ @@ -178,10 +177,10 @@ func (e *{{= normalizedStructName }}) {{= method }}({{= argBuilder.join(', ') }} {{? hasReturn }}var data {{= returnValue }}{{?}} err = e.internal.Execute(ctx, equinoxReq, {{? hasReturn }}&data{{?? true }}nil{{?}}) if err != nil { - logger.Error("Error executing request", zap.Error(err)) + logger.Error().Err(err).Msg("Error executing request") return {{= isPrimitiveType ? `*new(${returnValue})` : "nil"}}{{? hasReturn }}, err{{?}} } - logger.Debug("Method executed successfully") + logger.Debug().Msg("Method executed successfully") return {{? hasReturn }}{{= isPrimitiveType ? "data" : "&data" }}, nil{{?? true }}{{= isPrimitiveType ? `*new(${returnValue})` : "nil" }} {{?}} } diff --git a/test/README.md b/test/README.md index fc6f062..b8ec4b4 100644 --- a/test/README.md +++ b/test/README.md @@ -1,5 +1,15 @@ # Tests +## Benchmark + +Benchmarks are separated in three files: parallel, data and cache. + +- parallel: Variety of benchmarks to test parallelism. Used more as a test than a benchmark. +- cache: Cache benchmarks for both BigCache and Redis. +- data: Benchmarks that use data from the live Riot Games API, located in the `data` folder. + +Benchmarks should be using a configuration closest to the one used in production, with cache disabled when possible and loglevel set to warn. + ## Integration > Integration tests are meant to be run manually. diff --git a/test/benchmark/benchmark_test.go b/test/benchmark/cache_test.go similarity index 60% rename from test/benchmark/benchmark_test.go rename to test/benchmark/cache_test.go index 21d3032..b1e8b03 100644 --- a/test/benchmark/benchmark_test.go +++ b/test/benchmark/cache_test.go @@ -3,13 +3,18 @@ package benchmark_test import ( "context" "fmt" + "net/http" "testing" + "time" "github.com/Kyagara/equinox" "github.com/Kyagara/equinox/api" + "github.com/Kyagara/equinox/cache" "github.com/Kyagara/equinox/clients/lol" "github.com/Kyagara/equinox/test/util" "github.com/h2non/gock" + "github.com/redis/go-redis/v9" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) @@ -24,8 +29,7 @@ BenchmarkCachedSummonerByPUUID-16 140514 8479 ns/op 3839 B/op 20 allocs/op BenchmarkCachedSummonerByPUUID-16 137011 8501 ns/op 3900 B/op 20 allocs/op BenchmarkCachedSummonerByPUUID-16 138278 8637 ns/op 3878 B/op 20 allocs/op */ -// This version and the non cached version are used to estimate how the cache impacts performance. -func BenchmarkCachedSummonerByPUUID(b *testing.B) { +func BenchmarkInMemoryCachedSummonerByPUUID(b *testing.B) { b.ReportAllocs() summoner := &lol.SummonerV4DTO{ @@ -55,6 +59,63 @@ func BenchmarkCachedSummonerByPUUID(b *testing.B) { } } +/* +goos: linux - WSL2 +goarch: amd64 +pkg: github.com/Kyagara/equinox/test/benchmark +cpu: AMD Ryzen 7 2700 Eight-Core Processor +BenchmarkRedisCachedSummonerByPUUID-16 19364 63955 ns/op 1688 B/op 26 allocs/op +BenchmarkRedisCachedSummonerByPUUID-16 17704 62345 ns/op 1688 B/op 26 allocs/op +BenchmarkRedisCachedSummonerByPUUID-16 19080 62095 ns/op 1689 B/op 26 allocs/op +BenchmarkRedisCachedSummonerByPUUID-16 19125 64048 ns/op 1689 B/op 26 allocs/op +BenchmarkRedisCachedSummonerByPUUID-16 18139 62999 ns/op 1689 B/op 26 allocs/op +*/ +func BenchmarkRedisCachedSummonerByPUUID(b *testing.B) { + b.ReportAllocs() + + summoner := &lol.SummonerV4DTO{ + ID: "5kIdR5x9LO0pVU_v01FtNVlb-dOws-D04GZCbNOmxCrB7A", + AccountID: "NkJ3FK5BQcrpKtF6Rj4PrAe9Nqodd2rwa5qJL8kJIPN_BkM", + PUUID: "6WQtgEvp61ZJ6f48qDZVQea1RYL9akRy7lsYOIHH8QDPnXr4E02E-JRwtNVE6n6GoGSU1wdXdCs5EQ", + Name: "Phanes", + ProfileIconID: 1386, + RevisionDate: 1657211888000, + SummonerLevel: 68, + } + + gock.New(fmt.Sprintf(api.RIOT_API_BASE_URL_FORMAT, lol.BR1)). + Get("/lol/summoner/v4/summoners/by-puuid/puuid"). + Persist(). + Reply(200). + JSON(summoner) + + ctx := context.Background() + redisConfig := &redis.Options{ + Network: "tcp", + Addr: "127.0.0.1:6379", + } + cache, err := cache.NewRedis(ctx, redisConfig, 4*time.Minute) + require.Nil(b, err) + config := &api.EquinoxConfig{ + Key: "RGAPI-TEST", + LogLevel: zerolog.WarnLevel, + HTTPClient: &http.Client{ + Timeout: 15 * time.Second, + }, + Retry: 1, + Cache: cache, + } + client, err := equinox.NewClientWithConfig(config) + require.Nil(b, err) + + for i := 0; i < b.N; i++ { + ctx := context.Background() + data, err := client.LOL.SummonerV4.ByPUUID(ctx, lol.BR1, "puuid") + require.Nil(b, err) + require.Equal(b, "Phanes", data.Name) + } +} + /* goos: linux - WSL2 goarch: amd64 @@ -86,7 +147,7 @@ func BenchmarkSummonerByPUUID(b *testing.B) { JSON(summoner) config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) diff --git a/test/benchmark/data_test.go b/test/benchmark/data_test.go index 591917c..0999152 100644 --- a/test/benchmark/data_test.go +++ b/test/benchmark/data_test.go @@ -12,6 +12,7 @@ import ( "github.com/Kyagara/equinox/clients/val" "github.com/Kyagara/equinox/test/util" "github.com/h2non/gock" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) @@ -40,7 +41,7 @@ func BenchmarkMatchByID(b *testing.B) { JSON(res) config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) @@ -79,7 +80,7 @@ func BenchmarkMatchTimeline(b *testing.B) { JSON(res) config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) @@ -118,7 +119,7 @@ func BenchmarkDDragonAllChampions(b *testing.B) { JSON(data) config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) @@ -158,7 +159,7 @@ func BenchmarkVALContentAllLocales(b *testing.B) { JSON(res) config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) diff --git a/test/benchmark/parallel_test.go b/test/benchmark/parallel_test.go index 40ee283..e485b1c 100644 --- a/test/benchmark/parallel_test.go +++ b/test/benchmark/parallel_test.go @@ -11,12 +11,10 @@ import ( "github.com/Kyagara/equinox/ratelimit" "github.com/Kyagara/equinox/test/util" "github.com/h2non/gock" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) -// These parallel benchmarks are more of a test less of an benchmark. -// Used to see how the library reacts to some parallel work. - // This revealed problems with multiple limits in a bucket, only the first bucket was being respected. func BenchmarkParallelRateLimit(b *testing.B) { b.ReportAllocs() @@ -41,7 +39,7 @@ func BenchmarkParallelRateLimit(b *testing.B) { JSON(summoner) config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) @@ -131,7 +129,7 @@ func BenchmarkParallelSummonerByPUUID(b *testing.B) { JSON(summoner) config := util.NewTestEquinoxConfig() - config.LogLevel = api.WARN_LOG_LEVEL + config.LogLevel = zerolog.WarnLevel config.Retry = 1 client, err := equinox.NewClientWithConfig(config) diff --git a/test/integration/equinox_test.go b/test/integration/equinox_test.go index 7f7a370..6e3ebbf 100644 --- a/test/integration/equinox_test.go +++ b/test/integration/equinox_test.go @@ -15,6 +15,7 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/cache" "github.com/allegro/bigcache/v3" + "github.com/rs/zerolog" ) var ( @@ -44,7 +45,7 @@ func init() { } config := &api.EquinoxConfig{ Key: key, - LogLevel: api.DEBUG_LOG_LEVEL, + LogLevel: zerolog.DebugLevel, HTTPClient: &http.Client{ Timeout: 15 * time.Second, }, diff --git a/test/util/util.go b/test/util/util.go index 22dca5c..074e014 100644 --- a/test/util/util.go +++ b/test/util/util.go @@ -7,6 +7,7 @@ import ( "github.com/Kyagara/equinox/api" "github.com/Kyagara/equinox/cache" jsonv2 "github.com/go-json-experiment/json" + "github.com/rs/zerolog" ) // Creates an EquinoxConfig for tests. @@ -18,7 +19,7 @@ import ( func NewTestEquinoxConfig() *api.EquinoxConfig { return &api.EquinoxConfig{ Key: "RGAPI-TEST", - LogLevel: api.DEBUG_LOG_LEVEL, + LogLevel: zerolog.DebugLevel, HTTPClient: &http.Client{}, Retry: 0, Cache: &cache.Cache{TTL: 0},