logjam_agent 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,8 @@ module LogjamAgent
9
9
 
10
10
  def initialize(*args)
11
11
  super(*args)
12
- # stupid bug in the buffered logger code
13
- @log.write "\n"
12
+ # stupid bug in the buffered logger code (Rails::VERSION::STRING < "3.2")
13
+ @log.write "\n" if respond_to?(:buffer)
14
14
  @formatter = lambda{|_, _, _, message| message}
15
15
  end
16
16
 
@@ -47,15 +47,27 @@ module LogjamAgent
47
47
  end
48
48
  end
49
49
  time = Time.now
50
- buffer << formatter.call(severity, time, progname, message) << "\n"
51
- auto_flush
50
+ formatted_message = formatter.call(severity, time, progname, message)
51
+ if respond_to?(:buffer)
52
+ buffer << formatted_message << "\n"
53
+ auto_flush
54
+ else # @log is a logger
55
+ @log << "#{formatted_message}\n"
56
+ end
52
57
  request.add_line(severity, time, message) if request
53
58
  message
54
59
  end
55
60
 
56
61
  def logdev=(log_device)
57
62
  raise "cannot connect logger to new log device" unless log_device.respond_to?(:write)
58
- @log = log_device
63
+ if respond_to?(:buffer)
64
+ @log = log_device
65
+ else
66
+ @log.instance_eval do
67
+ raise "cannot set log device" unless defined?(@logdev)
68
+ @logdev = log_device
69
+ end
70
+ end
59
71
  end
60
72
 
61
73
  private
@@ -1,14 +1,21 @@
1
1
  require 'logjam_agent'
2
2
  module LogjamAgent
3
+
4
+ module Rack
5
+ autoload :Logger, 'logjam_agent/rack/logger'
6
+ end
7
+ autoload :Middleware, 'logjam_agent/middleware'
8
+
3
9
  class Railtie < Rails::Railtie
4
10
 
5
11
  initializer "initialize_logjam_agent_logger", :before => :initialize_logger do |app|
6
12
  Rails.logger ||= app.config.logger ||
7
13
  begin
8
- path = app.config.paths.log.to_a.first
14
+ paths = app.config.paths
15
+ path = (paths.respond_to?(:log) ? paths.log.to_a : paths['log']).first.to_s
9
16
  logger = LogjamAgent::BufferedLogger.new(path)
10
17
  logger.level = ActiveSupport::BufferedLogger.const_get(app.config.log_level.to_s.upcase)
11
- logger.auto_flushing = false if Rails.env.production?
18
+ logger.auto_flushing = false if Rails.env.production? && Rails::VERSION::STRING < "3.2"
12
19
  logger
13
20
  rescue StandardError => e
14
21
  logger = LogjamAgent::BufferedLogger.new(STDERR)
@@ -24,11 +31,6 @@ module LogjamAgent
24
31
  initializer "logjam_agent", :after => "time_bandits" do |app|
25
32
  app.config.middleware.swap("TimeBandits::Rack::Logger", "LogjamAgent::Rack::Logger")
26
33
  app.config.middleware.insert_before("LogjamAgent::Rack::Logger", "LogjamAgent::Middleware")
27
-
28
- ActiveSupport.on_load(:action_controller) do
29
- require 'logjam_agent/middleware.rb'
30
- require 'logjam_agent/rack/logger.rb'
31
- end
32
34
  end
33
35
 
34
36
  end
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.3.6"
2
+ VERSION = "0.4.0"
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: 31
5
- prerelease:
4
+ hash: 15
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 6
10
- version: 0.3.6
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stefan Kaes
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-27 00:00:00 Z
18
+ date: 2012-04-05 00:00:00 +02:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rake
@@ -116,6 +117,7 @@ files:
116
117
  - lib/logjam_agent/version.rb
117
118
  - logjam_agent.gemspec
118
119
  - rails/init.rb
120
+ has_rdoc: true
119
121
  homepage: ""
120
122
  licenses: []
121
123
 
@@ -145,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
147
  requirements: []
146
148
 
147
149
  rubyforge_project: logjam_agent
148
- rubygems_version: 1.8.10
150
+ rubygems_version: 1.3.7
149
151
  signing_key:
150
152
  specification_version: 3
151
153
  summary: Logjam client library to be used with logjam