Module: Justlogging
- Defined in:
- lib/justlogging.rb
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.log_key ⇒ Object
Returns the value of attribute log_key.
Class Method Summary collapse
- .configure {|_self| ... } ⇒ Object
- .log(entry, log_key = self.log_key) ⇒ Object
- .logger ⇒ Object
- .url ⇒ Object
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/justlogging.rb', line 8 def api_key @api_key end |
.log_key ⇒ Object
Returns the value of attribute log_key.
8 9 10 |
# File 'lib/justlogging.rb', line 8 def log_key @log_key end |
Class Method Details
.configure {|_self| ... } ⇒ Object
16 17 18 |
# File 'lib/justlogging.rb', line 16 def configure yield self end |
.log(entry, log_key = self.log_key) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/justlogging.rb', line 24 def log(entry, log_key = self.log_key) params = { 'log_key' => log_key, 'entry' => entry, 'access_key' => api_key } response = begin Net::HTTP.post_form(url, params) rescue TimeoutError => e logger.error "Timeout while connecting to justlogging." if logger nil end case response when Net::HTTPSuccess then logger.info "Justlogging OK" if logger else logger.error "Justlogging FAIL: #{response.body if response.respond_to? :body}" if logger end end |
.logger ⇒ Object
10 11 12 13 14 |
# File 'lib/justlogging.rb', line 10 def logger ActiveRecord::Base.logger rescue @logger ||= Logger.new(STDERR) end |
.url ⇒ Object
20 21 22 |
# File 'lib/justlogging.rb', line 20 def url URI.parse('http://logs.justlogging.com/log') end |