justlogging 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -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.
data/README.textile ADDED
@@ -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
+ Install it as a gem (on gemcutter):
12
+
13
+ <pre>
14
+ <code>
15
+ gem install justlogging
16
+ </code>
17
+ </pre>
18
+
19
+ For rails:
20
+
21
+ Add this to your enviroment.rb
22
+ <pre>
23
+ <code>
24
+ config.gem "justlogging", :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,52 @@
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 alert(entry, log_key = self.log_key)
25
+ log(entry, log_key, true)
26
+ end
27
+
28
+ def log(entry, log_key = self.log_key, alert = false)
29
+ params = {
30
+ 'log_key' => log_key,
31
+ 'entry' => entry,
32
+ 'access_key' => api_key
33
+ }
34
+ params['alert'] = 'true' if alert
35
+
36
+ response = begin
37
+ Net::HTTP.post_form(url, params)
38
+ rescue TimeoutError => e
39
+ logger.error "Timeout while connecting to justlogging." if logger
40
+ nil
41
+ end
42
+
43
+ case response
44
+ when Net::HTTPSuccess then
45
+ logger.info "Justlogging OK" if logger
46
+ else
47
+ logger.error "Justlogging FAIL: #{response.body if response.respond_to? :body}" if logger
48
+ end
49
+ end
50
+
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: justlogging
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.5
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: info@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: justlogging is a justlogging API wrapper
59
+ test_files: []
60
+