logjam_agent 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/logjam_agent.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "socket"
1
2
  require "logjam_agent/version"
2
3
  require "logjam_agent/amqp_forwarder"
3
4
  require "logjam_agent/forwarders"
@@ -18,6 +19,18 @@ module LogjamAgent
18
19
  mattr_accessor :environment_name
19
20
  self.environment_name = nil
20
21
 
22
+ def self.get_hostname
23
+ n = Socket.gethostname
24
+ if n.split('.').size > 1
25
+ n
26
+ else
27
+ Socket.gethostbyname(n) rescue n
28
+ end
29
+ end
30
+
31
+ mattr_accessor :hostname
32
+ self.hostname = self.get_hostname
33
+
21
34
  def self.disable!
22
35
  self.disabled = true
23
36
  end
@@ -3,7 +3,7 @@ module LogjamAgent
3
3
  class Logger < ActiveSupport::LogSubscriber
4
4
  def initialize(app)
5
5
  @app = app
6
- @hostname = Socket.gethostname
6
+ @hostname = LogjamAgent.hostname
7
7
  end
8
8
 
9
9
  def call(env)
@@ -1,17 +1,14 @@
1
1
  require "json"
2
- require "socket"
3
2
 
4
3
  module LogjamAgent
5
4
  class Request
6
5
  attr_reader :fields
7
6
 
8
- @@hostname = Socket.gethostname.split('.').first
9
-
10
7
  def initialize(app, env, logger, initial_fields)
11
8
  @logger = logger
12
9
  @forwarder = Forwarders.get(app, env)
13
10
  @lines = []
14
- @fields = initial_fields.merge(:host => @@hostname, :process_id => Process.pid, :lines => @lines)
11
+ @fields = initial_fields.merge(:host => LogjamAgent.hostname, :process_id => Process.pid, :lines => @lines)
15
12
  end
16
13
 
17
14
  def add_line(severity, timestamp, message)
@@ -1,10 +1,9 @@
1
- require 'socket'
2
1
  require 'logger'
3
2
 
4
3
  module LogjamAgent
5
4
  class SyslogLikeFormatter
6
5
  def initialize
7
- @hostname = Socket.gethostname.split('.').first
6
+ @hostname = LogjamAgent.hostname
8
7
  @app_name = "rails"
9
8
  @attributes = []
10
9
  end
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stefan Kaes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-06 00:00:00 +02:00
18
+ date: 2011-10-25 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency