loggerclient 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/LoggerClient.rb +72 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5496cae67dce59f31e7e059092c685c007bdd457
4
+ data.tar.gz: 774783807170cf4688e2b82c39e1e17c4d6a21a9
5
+ SHA512:
6
+ metadata.gz: b76863c31134d75fada02bd2731be666e058a91051779fd01da3341822d8ce77bd2322c9a2dcbe036b445fa7f5afcd53bdf207e896e30fa8d084275e438c3f30
7
+ data.tar.gz: 9638e4eb56855a5f559ba1129e773fb48253554dcaa31ee3d2331d8b3b10d49250230d51fb99c0f9746864015bdb79e18e3556a9297ad92278da14dc04cd8057
@@ -0,0 +1,72 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ # Ruby Client Library for Logger
5
+ # Use logger to easily log errors and debugging information in your apps.
6
+ # Author: Tim Davies <support@getlogger.com>
7
+ class LoggerClient
8
+ # Client version:
9
+ @version = '1.0.0'
10
+
11
+ # Empty API key:
12
+ @api_key = nil
13
+
14
+ # Base URL of API:
15
+ @base_url = "http://getlogger.com/logger/%s/"
16
+
17
+ # Initialiser function for setting the API key
18
+ def self.init (key)
19
+ @api_key = key
20
+ end
21
+
22
+ def self.getAPIURI
23
+ if @api_key == nil
24
+ raise "No API key set"
25
+ else
26
+ sprintf(@base_url, @api_key);
27
+ end
28
+ end
29
+
30
+ def self.sendMessage (options)
31
+ begin
32
+ postData = Net::HTTP.post_form(URI.parse(self.getAPIURI), options)
33
+ postJSON = JSON.parse(postData.body)
34
+
35
+ if postJSON['success'] then
36
+ return true
37
+ else
38
+ return false
39
+ end
40
+ rescue
41
+ return false
42
+ end
43
+ end
44
+
45
+ def self.error (message)
46
+ LoggerClient.sendMessage({
47
+ 'type' => 'error',
48
+ 'message' => message,
49
+ 'version' => @version
50
+ })
51
+ end
52
+
53
+ def self.warn (message)
54
+ LoggerClient.sendMessage({
55
+ 'type' => 'warn',
56
+ 'message' => message,
57
+ 'version' => @version
58
+ })
59
+ end
60
+
61
+ def self.info (message)
62
+ LoggerClient.sendMessage({
63
+ 'type' => 'info',
64
+ 'message' => message,
65
+ 'version' => @version
66
+ })
67
+ end
68
+
69
+ def self.log (message)
70
+ self.info(message)
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: loggerclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tim Davies
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Client for Logger - an easy way to log errors
14
+ email: support@getlogger.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/LoggerClient.rb
20
+ homepage: http://getlogger.com
21
+ licenses:
22
+ - BSD-2-Clause
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.6
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: LoggerClient
44
+ test_files: []