Skip to content

Commit

Permalink
Added Pusher.logger
Browse files Browse the repository at this point in the history
  • Loading branch information
ismasan committed Mar 28, 2010
1 parent 44c7bfb commit dd5fcef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -12,6 +12,11 @@ Request pusher credentials from <http://pusherapp.com> and configure the gem
Trigger an event

Pusher['arbitrary-channel-name'].trigger({:some => 'data'})

Logging
Errors are logger to Pusher.logger. You can set that to any logger you want, ie:

Pusher.logger = Rails.logger

Copyright
---------
Expand Down
10 changes: 6 additions & 4 deletions lib/pusher.rb
@@ -1,6 +1,7 @@
require 'json'
require 'uri'
require 'net/http'
require 'logger'

class Pusher

Expand All @@ -11,12 +12,13 @@ def message
end

class << self
attr_accessor :host, :port
attr_accessor :host, :port, :logger
attr_writer :key, :secret
end

self.host = 'api.pusherapp.com'
self.port = 80
self.host = 'api.pusherapp.com'
self.port = 80
self.logger = Logger.new($STDOUT)

def self.[](channel_id)
raise ArgumentError unless (@key && @secret)
Expand Down Expand Up @@ -58,7 +60,7 @@ def self.turn_into_json(data)
private

def handle_error(e)
puts e.inspect
self.logger.error(e.backtrace.join("\n"))
end

end
Expand Down

0 comments on commit dd5fcef

Please sign in to comment.