logglier 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,16 @@
1
- source :gemcutter
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem "jruby-openssl", :platforms => :jruby
5
+ platforms :jruby do
6
+ gem 'jruby-openssl'
7
+ gem 'json'
8
+ end
9
+
10
+ platforms :mri_18 do
11
+ gem 'json'
12
+ end
13
+
14
+ platforms :rbx do
15
+ gem 'json'
16
+ end
data/README.md CHANGED
@@ -55,6 +55,17 @@ Example:
55
55
  Logglier.new('https://logs.loggly.com/inputs/<id>',
56
56
  :threaded => true)
57
57
 
58
+ #### JSON Formatting
59
+
60
+ add the ':format => :json' when creating a new Logglier instance. Make
61
+ sure to use a HTTP input that has JSON enabled. Can also be used with
62
+ threaded delivery.
63
+
64
+ Example:
65
+
66
+ Logglier.new('https://logs.loggly.com/inputs/<id>',
67
+ :format => :json)
68
+
58
69
  ### Syslog TCP/UDP Inputs
59
70
 
60
71
  Logglier.new('[udp|tcp]://<hostname>:<port>/<facility>')
@@ -63,7 +74,6 @@ The facility is optional and defaults to 16 (local0) if none is
63
74
  specified. Facilities are just integers from 0 to 23, see
64
75
  <http://www.faqs.org/rfcs/rfc3164.html>
65
76
 
66
-
67
77
  Logging
68
78
  -------
69
79
 
@@ -1,3 +1,5 @@
1
+ require 'net/https'
2
+
1
3
  module Logglier
2
4
  module Client
3
5
  class HTTP
@@ -1,4 +1,3 @@
1
- require 'net/https'
2
1
  require 'uri'
3
2
 
4
3
  require File.join(File.dirname(__FILE__), 'http', 'sync')
@@ -13,6 +12,7 @@ module Logglier
13
12
 
14
13
  def initialize(opts={})
15
14
  setup_input_uri(opts)
15
+ @format = opts[:format] ? opts[:formt].to_sym : nil
16
16
  @deliverer = if opts[:threaded]
17
17
  Logglier::Client::HTTP::DeliveryThread.new(@input_uri, opts)
18
18
  else
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Logglier
2
4
  module Client
3
5
 
@@ -57,8 +59,14 @@ module Logglier
57
59
 
58
60
  def formatter
59
61
  proc do |severity, datetime, progname, msg|
60
- message = "#{datetime} "
61
- message << massage_message(msg, severity)
62
+ if @format == :json && msg.is_a?(Hash)
63
+ msg.merge!({ :severity => severity,
64
+ :datetime => datetime,
65
+ :progname => progname }).to_json
66
+ else
67
+ message = "#{datetime} "
68
+ message << massage_message(msg, severity)
69
+ end
62
70
  end
63
71
  end
64
72
 
@@ -1,3 +1,3 @@
1
1
  module Logglier
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
data/logglier.gemspec CHANGED
@@ -2,23 +2,24 @@ dir = File.dirname(__FILE__)
2
2
  require File.expand_path(File.join(dir, 'lib', 'logglier', 'version'))
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = "logglier"
5
+ s.name = 'logglier'
6
6
  s.version = Logglier::VERSION
7
7
  s.date = Time.now
8
- s.summary = "Loggly 'plugin' for Logger"
9
- s.description =<<EOD
10
- Logger => Loggly
11
- EOD
8
+ s.summary = 'Loggly "plugin" for Logger'
9
+ s.description = 'Logger => Loggly'
12
10
 
13
11
  s.authors = ["Edward Muller (aka freeformz)"]
14
- s.email = "edwardam@interlix.com"
15
- s.homepage = "http://github.com/freeformz/logglier"
12
+ s.email = 'edwardam@interlix.com'
13
+ s.homepage = 'http://github.com/freeformz/logglier'
16
14
 
17
15
  s.files = %w{ README.md Gemfile LICENSE logglier.gemspec Rakefile } + Dir["#{dir}/lib/**/*.rb"]
18
- s.require_paths = ["lib"]
16
+ s.require_paths = ['lib']
19
17
  s.test_files = Dir["#{dir}/spec/**/*.rb"]
20
18
 
21
- s.rubyforge_project = "logglier"
19
+ s.rubyforge_project = 'logglier'
20
+
21
+ s.required_ruby_version = '>= 1.8.7'
22
+ s.required_rubygems_version = '>= 1.3.6'
22
23
 
23
24
  s.add_development_dependency 'rake'
24
25
  s.add_development_dependency 'rspec', '~> 2.5.0'
data/spec/http_spec.rb CHANGED
@@ -20,8 +20,12 @@ describe 'HTTP' do
20
20
  @http.should_receive(:request_post).exactly(2).times.and_raise Errno::ECONNRESET
21
21
  @proxy.deliver('message')
22
22
  end
23
+
23
24
  it "fails for other errors" do
24
25
  @http.should_receive(:request_post).once.and_raise EOFError
25
26
  @proxy.deliver('message')
26
27
  end
28
+
29
+ describe "json format" do
30
+ end
27
31
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logglier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Edward Muller (aka freeformz)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-16 00:00:00 -07:00
18
+ date: 2011-06-22 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -48,9 +48,7 @@ dependencies:
48
48
  version: 2.5.0
49
49
  type: :development
50
50
  version_requirements: *id002
51
- description: |
52
- Logger => Loggly
53
-
51
+ description: Logger => Loggly
54
52
  email: edwardam@interlix.com
55
53
  executables: []
56
54
 
@@ -68,14 +66,14 @@ files:
68
66
  - ./lib/logglier/client/http/threaded.rb
69
67
  - ./lib/logglier/client/http.rb
70
68
  - ./lib/logglier/client/syslog.rb
71
- - ./lib/logglier/client.rb
72
69
  - ./lib/logglier/version.rb
70
+ - ./lib/logglier/client.rb
73
71
  - ./lib/logglier.rb
74
- - ./spec/client_spec.rb
75
72
  - ./spec/http_spec.rb
76
- - ./spec/logglier_spec.rb
77
- - ./spec/spec_helper.rb
78
73
  - ./spec/threaded_spec.rb
74
+ - ./spec/spec_helper.rb
75
+ - ./spec/client_spec.rb
76
+ - ./spec/logglier_spec.rb
79
77
  has_rdoc: true
80
78
  homepage: http://github.com/freeformz/logglier
81
79
  licenses: []
@@ -90,29 +88,33 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
88
  requirements:
91
89
  - - ">="
92
90
  - !ruby/object:Gem::Version
93
- hash: 3
91
+ hash: 57
94
92
  segments:
95
- - 0
96
- version: "0"
93
+ - 1
94
+ - 8
95
+ - 7
96
+ version: 1.8.7
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- hash: 3
102
+ hash: 23
103
103
  segments:
104
- - 0
105
- version: "0"
104
+ - 1
105
+ - 3
106
+ - 6
107
+ version: 1.3.6
106
108
  requirements: []
107
109
 
108
110
  rubyforge_project: logglier
109
- rubygems_version: 1.5.2
111
+ rubygems_version: 1.6.2
110
112
  signing_key:
111
113
  specification_version: 3
112
- summary: Loggly 'plugin' for Logger
114
+ summary: Loggly "plugin" for Logger
113
115
  test_files:
114
- - ./spec/client_spec.rb
115
116
  - ./spec/http_spec.rb
116
- - ./spec/logglier_spec.rb
117
- - ./spec/spec_helper.rb
118
117
  - ./spec/threaded_spec.rb
118
+ - ./spec/spec_helper.rb
119
+ - ./spec/client_spec.rb
120
+ - ./spec/logglier_spec.rb