Skip to content

Prevent boot/register if $level == none (reopened) #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 13, 2017

Conversation

ArturMoczulski
Copy link

This is a reopened PR for an accidentally closed PR #11

This will helps prevent errors during a first deploy in some cases(e.g.: if the .env file has not been setup until later in the process).
$hasConfig = $this->app['config']->has('services.rollbar');

return $hasLevel === false || ($hasToken === false && $hasConfig === false);
}
Copy link

@drbyte drbyte Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will sufficiently handle the necessary logic:

    public function stop()
    {
        $level = getenv('ROLLBAR_LEVEL') ?: $this->app->config->get('services.rollbar.level', null);
        $token = getenv('ROLLBAR_TOKEN') ?: $this->app->config->get('services.rollbar.token', null);
        $hasToken = empty($token) === false;

        return $hasToken === false || $level === 'none';
    }
  • if token not provided, then don't register
  • if level === 'none' then don't register

No need to check for config.services.rollbar as well, as long as we test both getenv and config at same time.
No need to check for empty "level", since line 80 already defaults to 'debug' if no level specified.

This is what I'm using now today after a bunch of testing.

@ArturMoczulski
Copy link
Author

LGTM. Applied @drbyte changes and merged to master.

@ArturMoczulski ArturMoczulski merged commit 387d8cf into master Sep 13, 2017
@drbyte
Copy link

drbyte commented Sep 13, 2017

Thanks @tobz-nz and @ArturMoczulski ... this makes setup less cumbersome.

@bishopb bishopb deleted the github-pr-11-reopened branch March 20, 2021 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants