logcast 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4987f226063f0f967cf3d2dbe00c4f003dead333
4
+ data.tar.gz: 253fa25496ff47320d1ed696383e309416e712e5
5
+ SHA512:
6
+ metadata.gz: d43c06e4eaed35190d33ea2886c8ef8f6ced68948f44906ce3a5596ae52482f9aa92fd9c5eeb23210f71e398778302c0c379b683529eb99c0d5ee17261968824
7
+ data.tar.gz: aee1e3b2d43d12b77d58b3433f61f8f8d2997b8fbd8fb482b5443276557b304d37a5f269e8439928835d8827d51a6ae8114a56656d8dbcb8bf8d3e730bbdf7a7
data/lib/logcast.rb CHANGED
@@ -1,18 +1,15 @@
1
1
  module Logcast
2
2
  autoload :Broadcaster, 'logcast/broadcaster.rb'
3
- autoload :Broadcast, 'logcast/broadcast.rb'
4
3
 
5
4
  def self.engage!
6
- logger = if defined?(Rails.logger)
7
- Rails.logger
8
- elsif defined?(RAILS_DEFAULT_LOGGER)
9
- RAILS_DEFAULT_LOGGER
10
- else
11
- ActiveRecord::Base.logger
12
- end
13
-
14
- logger = logger.instance_variable_get(:@logger) if logger.class.name == "ActiveSupport::TaggedLogging"
5
+ class << Rails
6
+ alias_method(:old_logger=, :logger=)
15
7
 
16
- logger.extend(Logcast::Broadcast)
8
+ def logger=(logger)
9
+ broadcast = Logcast::Broadcaster.new
10
+ broadcast.subscribe(logger)
11
+ self.old_logger = broadcast
12
+ end
13
+ end
17
14
  end
18
15
  end
@@ -1,18 +1,4 @@
1
- require 'logger'
2
-
3
- class Logcast::Broadcaster < ::Logger
4
- def initialize(io, *args)
5
- if io.is_a?(Logger)
6
- @logdev = io.instance_variable_get(:@logdev)
7
-
8
- self.level = io.level
9
- self.formatter = io.formatter
10
- self.progname = io.progname
11
- else
12
- super
13
- end
14
- end
15
-
1
+ class Logcast::Broadcaster
16
2
  def subscribe(subscriber, &block)
17
3
  unless subscriber.respond_to?(:add)
18
4
  original_subscriber = subscriber
@@ -40,16 +26,17 @@ class Logcast::Broadcaster < ::Logger
40
26
  @subscribers ||= []
41
27
  end
42
28
 
43
- # Rails 3
44
- def add(*args)
45
- super
46
- subscribers.each { |subscriber| subscriber.add(*args) }
47
- end
29
+ def method_missing(name, *args, &block)
30
+ responded = false
31
+
32
+ subscribers.each do |subscriber|
33
+ if subscriber.respond_to?(name)
34
+ responded = true
35
+ subscriber.send(name, *args, &block)
36
+ end
37
+ end
48
38
 
49
- # Rails 2
50
- def write(msg)
51
- self << msg
52
- subscribers.each { |subscriber| subscriber.add(level, msg.rstrip, progname) }
39
+ super unless responded
53
40
  end
54
41
 
55
42
  private
data/lib/logcast/rails.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'logcast'
2
- Logcast.engage!
3
2
 
4
- if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR == 3
5
- # Rails 3 bug, method missing is delegated without a block :/
6
- ActiveSupport::TaggedLogging.class_eval do
7
- def method_missing(method, *args, &block)
8
- @logger.send(method, *args, &block)
3
+ module Logcast
4
+ class Railtie < Rails::Railtie
5
+ config.before_configuration do
6
+ Logcast.engage!
9
7
  end
10
8
  end
11
9
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logcast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Steven Davidovitz
@@ -10,38 +9,34 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-07-20 00:00:00.000000000 Z
12
+ date: 2014-01-02 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rake
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: activesupport
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  description: Broadcasts logs, including support for Rails version 2.3 through 3.2.
@@ -51,33 +46,31 @@ executables: []
51
46
  extensions: []
52
47
  extra_rdoc_files: []
53
48
  files:
54
- - lib/logcast/broadcast.rb
55
49
  - lib/logcast/broadcaster.rb
56
50
  - lib/logcast/rails.rb
57
51
  - lib/logcast.rb
58
52
  homepage: http://developer.zendesk.com
59
53
  licenses:
60
54
  - Apache License Version 2.0
55
+ metadata: {}
61
56
  post_install_message:
62
57
  rdoc_options: []
63
58
  require_paths:
64
59
  - lib
65
60
  required_ruby_version: !ruby/object:Gem::Requirement
66
- none: false
67
61
  requirements:
68
- - - ! '>='
62
+ - - '>='
69
63
  - !ruby/object:Gem::Version
70
64
  version: 1.8.7
71
65
  required_rubygems_version: !ruby/object:Gem::Requirement
72
- none: false
73
66
  requirements:
74
- - - ! '>='
67
+ - - '>='
75
68
  - !ruby/object:Gem::Version
76
69
  version: 1.3.6
77
70
  requirements: []
78
71
  rubyforge_project:
79
- rubygems_version: 1.8.25
72
+ rubygems_version: 2.0.14
80
73
  signing_key:
81
- specification_version: 3
74
+ specification_version: 4
82
75
  summary: Log Broadcaster
83
76
  test_files: []
@@ -1,14 +0,0 @@
1
- module Logcast::Broadcast
2
- def self.extended(obj)
3
- current_log = obj.instance_variable_get(:@log)
4
- obj.instance_variable_set(:@log, Logcast::Broadcaster.new(current_log))
5
- end
6
-
7
- def subscribe(*args, &block)
8
- @log.subscribe(*args, &block)
9
- end
10
-
11
- def subscribers
12
- @log.subscribers
13
- end
14
- end