uglier 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +1 -0
- data/Rakefile +1 -0
- data/lib/uglier.rb +1 -0
- data/lib/uglier/client.rb +64 -0
- data/lib/uglier/version.rb +3 -0
- data/uglier.gemspec +20 -0
- metadata +68 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Jeff Lee
|
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.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
uglier-ruby - a client for ugly, a UDP loggin service
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|
data/lib/uglier.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('./uglier/client', File.dirname(__FILE__))
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Uglier
|
5
|
+
class Client
|
6
|
+
|
7
|
+
DEFAULT_CONFIG = {
|
8
|
+
:host => '127.0.0.1',
|
9
|
+
:port => '8124',
|
10
|
+
:flags => 0,
|
11
|
+
:namespace => '',
|
12
|
+
:namespace_delimeter => '.',
|
13
|
+
}
|
14
|
+
|
15
|
+
attr_accessor :config
|
16
|
+
|
17
|
+
def initialize(config = {})
|
18
|
+
@config = DEFAULT_CONFIG.merge(config)
|
19
|
+
reset_queue
|
20
|
+
end
|
21
|
+
|
22
|
+
def log(data)
|
23
|
+
return if data.size == 0 # no data is being logged
|
24
|
+
|
25
|
+
# Add namespace prefix, if it exists
|
26
|
+
if (ns_prefix = namespace_prefix).size > 0
|
27
|
+
data = data.inject({}) do |memo, (k, v)|
|
28
|
+
memo[ns_prefix + k.to_s] = v
|
29
|
+
memo
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
socket.send(data.to_json, @config[:flags], @config[:host], @config[:port])
|
34
|
+
end
|
35
|
+
|
36
|
+
def queue(data)
|
37
|
+
data.each do |k, v|
|
38
|
+
@queue[k] ||= []
|
39
|
+
@queue[k].concat(v.is_a?(Array) ? v : [v])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def flush_queue
|
44
|
+
log(@queue)
|
45
|
+
reset_queue
|
46
|
+
end
|
47
|
+
|
48
|
+
def reset_queue
|
49
|
+
@queue = {}
|
50
|
+
end
|
51
|
+
|
52
|
+
def namespace_prefix
|
53
|
+
ns = @config[:namespace].to_s
|
54
|
+
ns.size > 0 ? (ns + @config[:namespace_delimeter].to_s) : ''
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def socket
|
60
|
+
@socket ||= UDPSocket.new
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
data/uglier.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
require 'uglier/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'uglier'
|
7
|
+
s.summary = 'A Ruby client for ugly, a generic UDP logging service'
|
8
|
+
s.description = s.summary
|
9
|
+
s.homepage = 'http://github.com/jeffomatic/uglier-ruby'
|
10
|
+
s.version = Uglier::VERSION
|
11
|
+
|
12
|
+
s.authors = [ 'Jeff Lee' ]
|
13
|
+
s.email = [ 'jeffomatic@gmail.com' ]
|
14
|
+
|
15
|
+
s.require_paths = ['lib']
|
16
|
+
s.files = %w( README.md Rakefile LICENSE uglier.gemspec )
|
17
|
+
s.files += Dir.glob('lib/**/*')
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'json', '~> 1.6.0'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uglier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeff Lee
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.0
|
30
|
+
description: A Ruby client for ugly, a generic UDP logging service
|
31
|
+
email:
|
32
|
+
- jeffomatic@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- LICENSE
|
40
|
+
- uglier.gemspec
|
41
|
+
- lib/uglier/client.rb
|
42
|
+
- lib/uglier/version.rb
|
43
|
+
- lib/uglier.rb
|
44
|
+
homepage: http://github.com/jeffomatic/uglier-ruby
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.21
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: A Ruby client for ugly, a generic UDP logging service
|
68
|
+
test_files: []
|