ramon 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/init.rb +1 -0
- data/lib/ramon.rb +13 -2
- data/lib/ramon/config.rb +44 -0
- data/lib/ramon/exception_data.rb +0 -0
- data/lib/ramon/logger.rb +13 -0
- data/lib/ramon/remote.rb +23 -0
- data/lib/ramon/version.rb +1 -1
- data/ramon.gemspec +1 -0
- metadata +24 -6
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ramon'
|
data/lib/ramon.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
-
|
1
|
+
def require_local(file)
|
2
|
+
require File.join(File.dirname(__FILE__), 'ramon', file)
|
3
|
+
end
|
4
|
+
|
5
|
+
require_local "version"
|
6
|
+
require_local "logger"
|
7
|
+
require_local "remote"
|
8
|
+
require_local "exception_data"
|
2
9
|
|
3
10
|
module Ramon
|
4
|
-
|
11
|
+
def self.log(message, level=nil)
|
12
|
+
log_hash = Log.log(message, level)
|
13
|
+
Remote.post('log', log_hash)
|
14
|
+
end
|
5
15
|
end
|
16
|
+
|
data/lib/ramon/config.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Ramon
|
4
|
+
class Config
|
5
|
+
class ConfigurationException < StandardError; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
DEFAULTS = {
|
9
|
+
:host => 'http://127.0.0.1',
|
10
|
+
:port => 2464
|
11
|
+
}
|
12
|
+
|
13
|
+
def load
|
14
|
+
config_file ||= "/etc/amon.conf"
|
15
|
+
|
16
|
+
if File.file?(config_file)
|
17
|
+
begin
|
18
|
+
f = File.read(config_file)
|
19
|
+
config = JSON.parse(f)
|
20
|
+
|
21
|
+
@app_key = config['application_key'] unless config['application_key'].nil?
|
22
|
+
@port = config['web_app']['port'].to_i unless config['web_app']['port'].nil?
|
23
|
+
@host = config['web_app']['host'].to_s unless config['web_app']['host'].nil?
|
24
|
+
|
25
|
+
rescue Exception => e
|
26
|
+
raise ConfigurationException.new("Unable to load configuration file: #{config_file}")
|
27
|
+
end
|
28
|
+
else
|
29
|
+
puts "Amon::Config.load - /etc/amon.conf not found"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def port
|
34
|
+
@port ||= DEFAULTS[:port]
|
35
|
+
end
|
36
|
+
|
37
|
+
def host
|
38
|
+
@host ||= DEFAULTS[:host]
|
39
|
+
end
|
40
|
+
|
41
|
+
end # self end
|
42
|
+
load
|
43
|
+
end # Config end
|
44
|
+
end # Module end
|
File without changes
|
data/lib/ramon/logger.rb
ADDED
data/lib/ramon/remote.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'zlib'
|
4
|
+
require "#{File.dirname(__FILE__)}/config"
|
5
|
+
|
6
|
+
module Ramon
|
7
|
+
class Remote
|
8
|
+
def self.post(type, data)
|
9
|
+
|
10
|
+
if type == 'log':
|
11
|
+
@url = '/api/log'
|
12
|
+
else
|
13
|
+
@url = '/api/exception'
|
14
|
+
end
|
15
|
+
|
16
|
+
req = Net::HTTP::Post.new(@url, initheader = {'Content-Type' =>'application/json'})
|
17
|
+
#req.body = Zlib::Deflate.deflate(data.to_json, Zlib::BEST_SPEED)
|
18
|
+
req.body = data.to_json
|
19
|
+
response = Net::HTTP.new(Config::host, Config::port).start {|http| http.request(req) }
|
20
|
+
#puts "Response #{response.code} #{response.message}: #{response.body}"
|
21
|
+
end
|
22
|
+
end # class end
|
23
|
+
end # module end
|
data/lib/ramon/version.rb
CHANGED
data/ramon.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ramon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- martinrusev
|
@@ -15,10 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-09 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: json
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
22
35
|
description: Amon client that provides logging and exception handling
|
23
36
|
email:
|
24
37
|
- martinrusev@zoho.com
|
@@ -32,7 +45,12 @@ files:
|
|
32
45
|
- .gitignore
|
33
46
|
- Gemfile
|
34
47
|
- Rakefile
|
48
|
+
- init.rb
|
35
49
|
- lib/ramon.rb
|
50
|
+
- lib/ramon/config.rb
|
51
|
+
- lib/ramon/exception_data.rb
|
52
|
+
- lib/ramon/logger.rb
|
53
|
+
- lib/ramon/remote.rb
|
36
54
|
- lib/ramon/version.rb
|
37
55
|
- ramon.gemspec
|
38
56
|
has_rdoc: true
|