razing_ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/razing_ruby/logger.rb +9 -14
- data/lib/razing_ruby/version.rb +1 -1
- metadata +2 -2
data/lib/razing_ruby/logger.rb
CHANGED
@@ -20,18 +20,11 @@ class Logger
|
|
20
20
|
end
|
21
21
|
|
22
22
|
class LogDevice
|
23
|
-
attr_reader :loggers
|
24
|
-
|
25
|
-
# Create the logger cache
|
26
|
-
def raze_initialize(*a, &b)
|
27
|
-
ruby_initialize(*a, &b)
|
28
|
-
@loggers ||= {}
|
29
|
-
end
|
30
23
|
|
31
24
|
# Write a log
|
32
25
|
def raze_write(*a, &b)
|
33
26
|
results = [ruby_write(*a, &b)]
|
34
|
-
|
27
|
+
loggers.values.map(&:logdev).reduce(results) do |out, logger|
|
35
28
|
logger.respond_to?(:write) ? out << logger.write(*a, &b) : out
|
36
29
|
end
|
37
30
|
end
|
@@ -40,23 +33,25 @@ class Logger
|
|
40
33
|
def add_logger(name, logger = nil)
|
41
34
|
name, logger = __prep_logger__(name, logger)
|
42
35
|
return false if logger.logdev == self
|
43
|
-
|
36
|
+
loggers[name] = logger
|
44
37
|
end
|
45
38
|
|
46
39
|
# Remove a logger
|
47
40
|
def del_logger(name)
|
48
|
-
|
49
|
-
|
41
|
+
loggers[name].close
|
42
|
+
loggers.delete(name)
|
50
43
|
end
|
51
44
|
|
52
45
|
# Get a logger
|
53
46
|
def get_logger(name)
|
54
|
-
|
47
|
+
loggers[name]
|
48
|
+
end
|
49
|
+
|
50
|
+
def loggers
|
51
|
+
@loggers ||= {}
|
55
52
|
end
|
56
53
|
|
57
54
|
# Swap the methods with the raze ones
|
58
|
-
alias_method :ruby_initialize, :initialize
|
59
|
-
alias_method :initialize, :raze_initialize
|
60
55
|
alias_method :ruby_write, :write
|
61
56
|
alias_method :write, :raze_write
|
62
57
|
|
data/lib/razing_ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: razing_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|