rails_logger 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ h1. Justlogging
2
+
3
+ This plugin enables easy logging from any Ruby application to our webservice.
4
+
5
+ For other languages checkout:
6
+ * http://www.github.com/justlogging/php_logger
7
+ * http://www.github.com/justlogging/python_logger
8
+
9
+ h2. Install
10
+
11
+ Just install it as a plugin:
12
+ <pre>
13
+ <code>
14
+ $ ./script/plugin install git://github.com/justlogging/rails_logger.git
15
+ $ ./script/generate justlogging
16
+ </code>
17
+ </pre>
18
+
19
+ Or install it as a gem:
20
+
21
+ Add this to your enviroment.rb
22
+ <pre>
23
+ <code>
24
+ config.gem "justlogging-rails_logger", :lib => 'justlogging'
25
+ </code>
26
+ </pre>
27
+ and run
28
+ <pre>
29
+ <code>
30
+ rake gems:install
31
+ script/generate justlogging
32
+ </code>
33
+ </pre>
34
+
35
+ The generator copies a file called @justlogging.rb@ to the @RAILS_ROOT/config/initializer@ directory. You need to set you api key there and optionally your default log key.
36
+
37
+
38
+
39
+ h2. Usage
40
+
41
+ @Justlogging.log('this is my first entry')@
42
+
43
+ Easy as pie.
44
+
45
+ Copyright (c) 2009 Justlogging, released under the MIT license
@@ -0,0 +1,9 @@
1
+ class JustloggingGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ m.directory 'config/initializers'
6
+ m.file 'justlogging.rb', 'config/initializers/justlogging.rb'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ Justlogging.configure do |config|
2
+ config.api_key = '1234567890'
3
+ config.log_key = '1234567890'
4
+ end
@@ -0,0 +1,47 @@
1
+ # Justlogging
2
+ require "uri"
3
+ require "net/http"
4
+
5
+ module Justlogging
6
+
7
+ class << self
8
+ attr_accessor :api_key, :log_key
9
+
10
+ def logger
11
+ ActiveRecord::Base.logger
12
+ rescue
13
+ @logger ||= Logger.new(STDERR)
14
+ end
15
+
16
+ def configure
17
+ yield self
18
+ end
19
+
20
+ def url
21
+ URI.parse('http://logs.justlogging.com/log')
22
+ end
23
+
24
+ def log(entry, log_key = self.log_key)
25
+ params = {
26
+ 'log_key' => log_key,
27
+ 'entry' => entry,
28
+ 'access_key' => api_key
29
+ }
30
+
31
+ response = begin
32
+ Net::HTTP.post_form(url, params)
33
+ rescue TimeoutError => e
34
+ logger.error "Timeout while connecting to justlogging." if logger
35
+ nil
36
+ end
37
+
38
+ case response
39
+ when Net::HTTPSuccess then
40
+ logger.info "Justlogging OK" if logger
41
+ else
42
+ logger.error "Justlogging FAIL: #{response.body if response.respond_to? :body}" if logger
43
+ end
44
+ end
45
+
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Robert Beekman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-13 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Justlogging is a webservice that allows you to log just about anything. This is the ruby gem for API interaction.
17
+ email: robert@justlogging.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - MIT-LICENSE
26
+ - README.textile
27
+ - lib/justlogging.rb
28
+ - generators/justlogging/justlogging_generator.rb
29
+ - generators/justlogging/templates/justlogging.rb
30
+ has_rdoc: true
31
+ homepage: http://github.com/justlogging/rails_logger
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options:
36
+ - --inline-source
37
+ - --charset=UTF-8
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.3.5
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: rails_logger is a justlogging API wrapper
59
+ test_files: []
60
+