coderberry / airbrake-grails

Airbrake Client for Grails
4 stars 7 forks source link

environment #9

Closed ghost closed 12 years ago

ghost commented 12 years ago

If the appender is configured as per the example in the docs

        def isProd = Environment.current == Environment.PRODUCTION

        def airbrakeAppender = new grails.plugins.airbrake.AirbrakeAppender(
                name: 'airbrake',
                api_key: '19467cfa091f0eb6e51c6350647bf213',
                filtered_keys: ['password'],
                env: (isProd ? 'production' : 'development'))

then when the app is running in the dev environment, the errors are logged in airbrake in the production environment. I tried using the configuration below instead:

        def airbrakeAppender = new grails.plugins.airbrake.AirbrakeAppender(
                name: 'airbrake',
                api_key: '19467cfa091f0eb6e51c6350647bf213',
                filtered_keys: ['password'],
                env: grails.util.Environment.current.name)

and it seems to resolve this problem. Perhaps it would make sense to use the above as the default value for the env property of AirbrakeAppender?

jonspalmer commented 12 years ago

There really isn't an issue here. You are free to declare the environment anyway you want the docs only give a suggestion. Are you saying just to change the docs?

ghost commented 12 years ago

Yes, I think the docs should be changed to my proposal above because this ensures that the environment in airbrake will have the same name as the Grails env. Remember that one can define environments in addition to dev, test, production.

However I also think that the env parameter should default to grails.util.Environment.current.name so that it can be omitted from the appender configuration, e.g.

        def airbrakeAppender = new grails.plugins.airbrake.AirbrakeAppender(
                name: 'airbrake',
                api_key: '19467cfa091f0eb6e51c6350647bf213',
                filtered_keys: ['password'])

Similarly, name could be given a default value of 'airbrake' so that the only required parameter is the api_key

jonspalmer commented 12 years ago

please just submit the pull request

coderberry commented 12 years ago

I agree. This is something that I would like to see as well. Please submit the pull request.