split_logger 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 markbates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ README
2
+ ========================================================================
3
+ split_logger was developed by: markbates
@@ -0,0 +1,4 @@
1
+ require 'logger'
2
+ Dir.glob(File.join(File.dirname(__FILE__), 'split_logger', '**/*.rb')).each do |f|
3
+ require File.expand_path(f)
4
+ end
@@ -0,0 +1,50 @@
1
+ class SplitLogger
2
+
3
+ attr_accessor :logger_list
4
+
5
+ def initialize(loggers = {})
6
+ self.logger_list = {}
7
+ loggers.each do |name, logger|
8
+ self.add(name, logger)
9
+ end
10
+ if defined?(RAILS_DEFAULT_LOGGER)
11
+ self.add(:rails_default_logger, RAILS_DEFAULT_LOGGER)
12
+ end
13
+ end
14
+
15
+ def add(name, logger)
16
+ self.logger_list[name.to_sym] = logger
17
+ end
18
+
19
+ def remove(name)
20
+ name = name.to_sym
21
+ if self.logger_list.has_key?(name)
22
+ self.logger_list.delete(name)
23
+ end
24
+ end
25
+
26
+ def list
27
+ self.logger_list
28
+ end
29
+
30
+ [:debug, :info, :warn, :error, :fatal].each do |level|
31
+ define_method(level) do |*args|
32
+ if self.logger_list.empty?
33
+ logger = ::Logger.new(STDOUT)
34
+ self.add(:default, logger)
35
+ logger.send(level, *args)
36
+ else
37
+ self.logger_list.each do |name, logger|
38
+ begin
39
+ logger.send(level, *args)
40
+ rescue Exception => e
41
+ self.remove(name)
42
+ self.send(level, e.message)
43
+ self.send(level, "Removed logger '#{name}' from the logger list!")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: split_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - markbates
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-21 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: "split_logger was developed by: markbates"
17
+ email: ""
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - LICENSE
25
+ files:
26
+ - lib/split_logger/split_logger.rb
27
+ - lib/split_logger.rb
28
+ - README
29
+ - LICENSE
30
+ has_rdoc: true
31
+ homepage: ""
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project: magrathea
54
+ rubygems_version: 1.3.5
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: split_logger
58
+ test_files: []
59
+