Skip to content
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

Disable logtail integration by config.logtail.enabled = false #10

Open
mikz opened this issue Mar 26, 2023 · 5 comments
Open

Disable logtail integration by config.logtail.enabled = false #10

mikz opened this issue Mar 26, 2023 · 5 comments

Comments

@mikz
Copy link

mikz commented Mar 26, 2023

Hi,

When logtail-rails is required, it will automatically be enabled and changes development log output.

That is fine, but it would be great if logtail could actually be disabled in the environment config like everything in Rails.

Right now it has to be disabled by Logtail::Integrations::Rails.enabled = false, which is unexpected, since it provides config.logtail configuration object.

I'm happy to make a PR that takes config.logtail.enabled as the global configuration in the Railtie and disables the integration.

Looks like there are config.integrations.{active_record,action_view,action_controller} that could be configured, but still it would be nice to have one that manages them all.

@PetrHeinz
Copy link
Member

PetrHeinz commented Jul 12, 2023

Hi @mikz, it makes sense to follow conventional ways of configuration. Thanks for opening up the issue 🙌

I'd be a bit careful with disabling the Logtail Logger though, since it accepts an additional argument (for formatted data). Disabling it would result in ArgumentError (wrong number of arguments (given 2, expected 0..1)) when logging with additional data (e.g.: Rails.logger.error("some error", code: 1337)).

For this reason, I would rather not promote a way to disable the logger via configuration. What do you think?

You could reconfigure the logger with a different io_device (currently STDOUT by default for development) instead.

@mikz
Copy link
Author

mikz commented Jul 16, 2023

Interesting. I didn't know. That would be a serious problem.
If I'd be designing it, then I'd probably go with a different contract than extending the Logger API. I'd probably use the progname parameter to accept structured data. So you could do: logger.error(metadata) { message }.

Since it is already out there, then I'd at least ensure the development environment is not half configured to use logtail.
It can still use logtail logger, but the default configuration should keep the logging the same as without the gem required.
Or go all in and configure it to use logtail fully (but then give people an easy way out to go to the normal development log experience).

@PetrHeinz
Copy link
Member

Thanks for sharing your thoughts. The easy way out of sending logs to Better Stack would be to set the environment variable LOGTAIL_SKIP_LOGS=1. It will prevent logger from sending logs to us.

@gertjanjansen
Copy link

gertjanjansen commented Nov 29, 2023

It can still use logtail logger, but the default configuration should keep the logging the same as without the gem required.

+1 for this. I was surprised that installing the gem and not configuring anything immediately impacts the log format in development mode.

@furedal
Copy link

furedal commented Jun 13, 2024

Adding this gem removes stack-traces to the terminal output when running in my local environment.
The only way I found around this was by adding this gem under a group that excludes the environment that you run locally in the Gemfile like this:

group :production do
  gem 'logtail-rails'
end

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

No branches or pull requests

4 participants