urbanairship / ruby-library

A Ruby wrapper for the Urban Airship API.
Other
200 stars 117 forks source link

Change Log Locations #96

Closed mjquinlan2000 closed 6 years ago

mjquinlan2000 commented 8 years ago

I've noticed that the gem outputs logs to $ROOT/urbanairship.log and there is no configuration available to either change the Logger that is used or the location of the file. At the very least, I would like to output all logs to my $ROOT/logs/ directory. So my question is either 1) is there a way to do this already? or 2) Would this be something you would be open to changing through a pull request?

If it's a change that you think would be beneficial to the community, I'd be happy to code up a solution.

Thanks!

mjquinlan2000 commented 8 years ago

Ok so I was able to patch the Urbanairship::Loggable module with a Rails initializer ($ROOT/config/initializers/urbanairship.rb):

Urbanairship::Loggable.class_eval do
  def create_logger
    logger = Logger.new(File.join(Rails.root, 'log', 'urbanairship.log'))
    logger.datetime_format = '%Y-%m-%d %H:%M:%S'
    logger.progname = 'Urbanairship'
    logger
  end
end

It just overrides the create_logger method. I can still create a pull request if there's enough interest to make this configurable.

markaschneider commented 8 years ago

I think having a setter would be beneficial. I'd like to set it to Rails.logger (ideally not by overriding).

maxdbn commented 7 years ago

I would like an option to disable logging completely

StephaneRob commented 7 years ago

@mjquinlan2000 Need to use instance_eval instead of class_eval now.

pdxmele commented 7 years ago

Thanks! We'll take a look at this when we do our next release.

pdxmele commented 6 years ago

This is fixed with #106