junlarsen / RiotQuest

[Deprecated] PHP 7.1+ Library for the Riot Games API
MIT License
8 stars 3 forks source link

Logging #56

Closed WildEgo closed 5 years ago

WildEgo commented 5 years ago

Describe the feature you'd like I'd like to have it so I'm able to disable logging and or get the ability to log using Laravel's default solution.

junlarsen commented 5 years ago

You're now able to disable logging via

Client::setLogging(false);

I'll work out setting up Laravel logging soon.

This will be released under 1.3.7

WildEgo commented 5 years ago

Using LeagueAPI::setLogging(false);

throws me:

   Symfony\Component\Debug\Exception\FatalThrowableError  : Return value of RiotQuest\Components\Client\Application::getManager() must be an instance of RiotQuest\Components\RateLimit\RateLimiter, null returned

  at E:\XAMPP\htdocs\----\vendor\supergrecko\riot-quest\src\RiotQuest\Components\Client\Application.php:212
    208|      * @return RateLimiter
    209|      */
    210|     public function getManager(): RateLimiter
    211|     {
  > 212|         return $this->manager;
    213|     }
junlarsen commented 5 years ago

Looks like the service provider isn't registering properly. I'm going to look into it.

In the meantime, could you try manually adding RiotQuest\ServiceProviders\LeagueServiceProvider to your laravel config? If that doesn't work, create a new service provider which runs the Client::boot() method.

WildEgo commented 5 years ago

It just happens whenever I call setLogging besides that it's perfect, also any way we could move stuff like that to the .env file like other variables

junlarsen commented 5 years ago

Yeah it breaks on setLogging because the client tries to boot itself it it hasn't when you call the API. when you call setLogging it doesn't have that self recovery so it throws. Sure I can move it into the env variables.

junlarsen commented 5 years ago

This update will be released under the 1.5.0 tag. Please mind the backwards incompatible change by replacing any existing Client::setLogging(false) calls to Client::disableLogging()

You are now able to use this code in Laravel

// To retrieve a channel from laravel logger:
$logger = Log::channel('league'); // returns LoggerInterface

Client::setLogger($logger);