torquebox-core 2.1.0-java → 2.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/torquebox-core.jar +0 -0
- data/lib/torquebox-core.rb +2 -2
- data/lib/torquebox/logger.rb +17 -2
- data/spec/logger_spec.rb +24 -0
- metadata +10 -10
data/lib/torquebox-core.jar
CHANGED
Binary file
|
data/lib/torquebox-core.rb
CHANGED
data/lib/torquebox/logger.rb
CHANGED
@@ -43,7 +43,7 @@ module TorqueBox
|
|
43
43
|
return
|
44
44
|
end
|
45
45
|
|
46
|
-
class Logger
|
46
|
+
class Logger
|
47
47
|
|
48
48
|
def initialize name = nil
|
49
49
|
category = name || (TORQUEBOX_APP_NAME if defined? TORQUEBOX_APP_NAME) || "TorqueBox"
|
@@ -56,6 +56,15 @@ module TorqueBox
|
|
56
56
|
|
57
57
|
attr_accessor :level
|
58
58
|
|
59
|
+
def add(severity, message, progname, &block)
|
60
|
+
severities = ['debug', 'info', 'warn', 'error', 'fatal']
|
61
|
+
# default to warn for unknown log level since jboss logger
|
62
|
+
# doesn't support unknown
|
63
|
+
delegate = severity > (severities.length - 1) ? 'warn' : severities[severity]
|
64
|
+
params = params_for_logger([message, progname], block)
|
65
|
+
@logger.send(delegate, *params)
|
66
|
+
end
|
67
|
+
|
59
68
|
def method_missing(method, *args, &block)
|
60
69
|
delegate = method
|
61
70
|
is_boolean = false
|
@@ -65,7 +74,7 @@ module TorqueBox
|
|
65
74
|
end
|
66
75
|
self.class.class_eval do
|
67
76
|
define_method(method) do |*a, &b|
|
68
|
-
params =
|
77
|
+
params = params_for_logger(a, b)
|
69
78
|
params = [""] if params.empty? && !is_boolean
|
70
79
|
@logger.send(delegate, *params)
|
71
80
|
end
|
@@ -73,5 +82,11 @@ module TorqueBox
|
|
73
82
|
self.send(method, *args, &block)
|
74
83
|
end
|
75
84
|
|
85
|
+
private
|
86
|
+
|
87
|
+
def params_for_logger(args, block)
|
88
|
+
[ args[0] || (block && block.call) ].compact
|
89
|
+
end
|
90
|
+
|
76
91
|
end
|
77
92
|
end
|
data/spec/logger_spec.rb
CHANGED
@@ -38,5 +38,29 @@ describe TorqueBox::Logger do
|
|
38
38
|
logger = TorqueBox::Logger.new
|
39
39
|
logger.info(nil)
|
40
40
|
end
|
41
|
+
|
42
|
+
it "should support the add method" do
|
43
|
+
fake_logger = mock('logger')
|
44
|
+
org.jboss.logging::Logger.stub!(:getLogger).and_return(fake_logger)
|
45
|
+
logger = TorqueBox::Logger.new
|
46
|
+
|
47
|
+
fake_logger.should_receive(:debug).with('debug')
|
48
|
+
logger.add(Logger::DEBUG, 'debug', nil)
|
49
|
+
|
50
|
+
fake_logger.should_receive(:info).with('info')
|
51
|
+
logger.add(Logger::INFO, 'info', nil)
|
52
|
+
|
53
|
+
fake_logger.should_receive(:warn).with('warning')
|
54
|
+
logger.add(Logger::WARN, 'warning', nil)
|
55
|
+
|
56
|
+
fake_logger.should_receive(:error).with('error')
|
57
|
+
logger.add(Logger::ERROR, 'error', nil)
|
58
|
+
|
59
|
+
fake_logger.should_receive(:warn).with('unknown')
|
60
|
+
logger.add(Logger::UNKNOWN, 'unknown', nil)
|
61
|
+
|
62
|
+
fake_logger.should_receive(:warn).with('block')
|
63
|
+
logger.add(Logger::WARN, nil, nil) { 'block' }
|
64
|
+
end
|
41
65
|
end
|
42
66
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: torquebox-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.1.
|
5
|
+
version: 2.1.1
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- The TorqueBox Team
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-08-27 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -37,17 +37,17 @@ files:
|
|
37
37
|
- lib/torquebox-core.jar
|
38
38
|
- lib/torquebox-core.rb
|
39
39
|
- lib/gem_hook.rb
|
40
|
-
- lib/torquebox/registry.rb
|
41
40
|
- lib/torquebox/core.rb
|
42
|
-
- lib/torquebox/component_manager.rb
|
43
|
-
- lib/torquebox/kernel.rb
|
44
41
|
- lib/torquebox/service_registry.rb
|
45
|
-
- lib/torquebox/logger.rb
|
46
42
|
- lib/torquebox/injectors.rb
|
47
|
-
-
|
43
|
+
- lib/torquebox/logger.rb
|
44
|
+
- lib/torquebox/kernel.rb
|
45
|
+
- lib/torquebox/registry.rb
|
46
|
+
- lib/torquebox/component_manager.rb
|
48
47
|
- spec/kernel_spec.rb
|
49
|
-
- spec/
|
48
|
+
- spec/injectors_spec.rb
|
50
49
|
- spec/service_registry_spec.rb
|
50
|
+
- spec/logger_spec.rb
|
51
51
|
homepage: http://torquebox.org/
|
52
52
|
licenses:
|
53
53
|
- lgpl
|
@@ -76,7 +76,7 @@ signing_key:
|
|
76
76
|
specification_version: 3
|
77
77
|
summary: TorqueBox Core Gem
|
78
78
|
test_files:
|
79
|
-
- spec/injectors_spec.rb
|
80
79
|
- spec/kernel_spec.rb
|
81
|
-
- spec/
|
80
|
+
- spec/injectors_spec.rb
|
82
81
|
- spec/service_registry_spec.rb
|
82
|
+
- spec/logger_spec.rb
|