markbates-split_logger 1.0.0.20090921164554
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README +3 -0
- data/lib/split_logger/split_logger.rb +50 -0
- data/lib/split_logger.rb +4 -0
- metadata +58 -0
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,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
|
data/lib/split_logger.rb
ADDED
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: markbates-split_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.20090921164554
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- markbates
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-21 00:00:00 -07: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: false
|
31
|
+
homepage: ""
|
32
|
+
licenses:
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
version:
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
requirements: []
|
51
|
+
|
52
|
+
rubyforge_project: magrathea
|
53
|
+
rubygems_version: 1.3.5
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: split_logger
|
57
|
+
test_files: []
|
58
|
+
|