sgeorgi-logging 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +262 -0
- data/README.rdoc +115 -0
- data/Rakefile +32 -0
- data/data/bad_logging_1.rb +13 -0
- data/data/bad_logging_2.rb +21 -0
- data/data/logging.rb +42 -0
- data/data/logging.yaml +63 -0
- data/data/simple_logging.rb +13 -0
- data/examples/appenders.rb +47 -0
- data/examples/classes.rb +41 -0
- data/examples/consolidation.rb +83 -0
- data/examples/fork.rb +37 -0
- data/examples/formatting.rb +51 -0
- data/examples/hierarchies.rb +73 -0
- data/examples/layouts.rb +48 -0
- data/examples/loggers.rb +29 -0
- data/examples/names.rb +43 -0
- data/examples/simple.rb +17 -0
- data/lib/logging.rb +528 -0
- data/lib/logging/appender.rb +260 -0
- data/lib/logging/appenders.rb +137 -0
- data/lib/logging/appenders/buffering.rb +178 -0
- data/lib/logging/appenders/console.rb +60 -0
- data/lib/logging/appenders/email.rb +75 -0
- data/lib/logging/appenders/file.rb +75 -0
- data/lib/logging/appenders/growl.rb +197 -0
- data/lib/logging/appenders/io.rb +69 -0
- data/lib/logging/appenders/rolling_file.rb +327 -0
- data/lib/logging/appenders/string_io.rb +68 -0
- data/lib/logging/appenders/syslog.rb +210 -0
- data/lib/logging/config/configurator.rb +188 -0
- data/lib/logging/config/yaml_configurator.rb +191 -0
- data/lib/logging/layout.rb +117 -0
- data/lib/logging/layouts.rb +47 -0
- data/lib/logging/layouts/basic.rb +32 -0
- data/lib/logging/layouts/parseable.rb +211 -0
- data/lib/logging/layouts/pattern.rb +311 -0
- data/lib/logging/log_event.rb +45 -0
- data/lib/logging/logger.rb +504 -0
- data/lib/logging/repository.rb +232 -0
- data/lib/logging/root_logger.rb +61 -0
- data/lib/logging/stats.rb +278 -0
- data/lib/logging/utils.rb +201 -0
- data/lib/spec/logging_helper.rb +34 -0
- data/test/appenders/test_buffered_io.rb +176 -0
- data/test/appenders/test_console.rb +66 -0
- data/test/appenders/test_email.rb +170 -0
- data/test/appenders/test_file.rb +95 -0
- data/test/appenders/test_growl.rb +127 -0
- data/test/appenders/test_io.rb +129 -0
- data/test/appenders/test_rolling_file.rb +209 -0
- data/test/appenders/test_syslog.rb +194 -0
- data/test/benchmark.rb +86 -0
- data/test/config/test_configurator.rb +70 -0
- data/test/config/test_yaml_configurator.rb +40 -0
- data/test/layouts/test_basic.rb +42 -0
- data/test/layouts/test_json.rb +112 -0
- data/test/layouts/test_pattern.rb +198 -0
- data/test/layouts/test_yaml.rb +121 -0
- data/test/setup.rb +43 -0
- data/test/test_appender.rb +152 -0
- data/test/test_consolidate.rb +46 -0
- data/test/test_layout.rb +110 -0
- data/test/test_log_event.rb +80 -0
- data/test/test_logger.rb +699 -0
- data/test/test_logging.rb +267 -0
- data/test/test_repository.rb +158 -0
- data/test/test_root_logger.rb +81 -0
- data/test/test_stats.rb +274 -0
- data/test/test_utils.rb +116 -0
- data/version.txt +1 -0
- metadata +227 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), %w[.. setup])
|
3
|
+
|
4
|
+
module TestLogging
|
5
|
+
module TestConfig
|
6
|
+
|
7
|
+
class TestConfigurator < Test::Unit::TestCase
|
8
|
+
include LoggingTestCase
|
9
|
+
|
10
|
+
def test_configuration
|
11
|
+
begin
|
12
|
+
load Logging.path(%w[data logging.rb])
|
13
|
+
rescue Exception => err
|
14
|
+
flunk err.inspect
|
15
|
+
end
|
16
|
+
|
17
|
+
levels = {
|
18
|
+
'deb' => 0,
|
19
|
+
'inf' => 1,
|
20
|
+
'prt' => 2,
|
21
|
+
'wrn' => 3,
|
22
|
+
'err' => 4,
|
23
|
+
'fat' => 5
|
24
|
+
}
|
25
|
+
assert_equal levels, Logging::LEVELS
|
26
|
+
assert_equal :inspect, Logging::OBJ_FORMAT
|
27
|
+
|
28
|
+
hash = Logging::Repository.instance.instance_variable_get(:@h)
|
29
|
+
assert hash.has_key?('A::B::C')
|
30
|
+
assert hash.has_key?('yourlogger')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_simple_configuration
|
34
|
+
begin
|
35
|
+
load Logging.path(%w[data simple_logging.rb])
|
36
|
+
rescue Exception => err
|
37
|
+
flunk err.inspect
|
38
|
+
end
|
39
|
+
|
40
|
+
levels = {
|
41
|
+
'debug' => 0,
|
42
|
+
'info' => 1,
|
43
|
+
'warn' => 2,
|
44
|
+
'error' => 3,
|
45
|
+
'fatal' => 4
|
46
|
+
}
|
47
|
+
assert_equal levels, Logging::LEVELS
|
48
|
+
assert_equal false, Logging.const_defined?('OBJ_FORMAT')
|
49
|
+
|
50
|
+
root = Logging::Logger.root
|
51
|
+
assert_equal 1, root.level
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_bad_appender_configuration
|
55
|
+
assert_raise(Logging::Config::Configurator::Error) {
|
56
|
+
load Logging.path(%w[data bad_logging_1.rb])
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_bad_layout_configuration
|
61
|
+
assert_raise(Logging::Config::Configurator::Error) {
|
62
|
+
load Logging.path(%w[data bad_logging_2.rb])
|
63
|
+
}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end # module TestConfig
|
68
|
+
end # module TestLogging
|
69
|
+
|
70
|
+
# EOF
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), %w[.. setup])
|
3
|
+
|
4
|
+
module TestLogging
|
5
|
+
module TestConfig
|
6
|
+
|
7
|
+
class TestYamlConfigurator < Test::Unit::TestCase
|
8
|
+
include LoggingTestCase
|
9
|
+
|
10
|
+
def test_class_load
|
11
|
+
assert_raise(::Logging::Config::YamlConfigurator::Error) {
|
12
|
+
::Logging::Config::YamlConfigurator.load(Object.new)
|
13
|
+
}
|
14
|
+
|
15
|
+
begin
|
16
|
+
fd = File.open('data/logging.yaml','r')
|
17
|
+
assert_nothing_raised {
|
18
|
+
::Logging::Config::YamlConfigurator.load(fd)
|
19
|
+
}
|
20
|
+
ensure
|
21
|
+
fd.close
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_initialize
|
26
|
+
io = StringIO.new
|
27
|
+
io << YAML.dump({:one => 1, :two => 2, :three => 3})
|
28
|
+
io.seek 0
|
29
|
+
|
30
|
+
assert_raise(::Logging::Config::YamlConfigurator::Error) {
|
31
|
+
::Logging::Config::YamlConfigurator.new(io, :meh)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
end # class TestYamlConfigurator
|
36
|
+
|
37
|
+
end # module TestConfig
|
38
|
+
end # module TestLogging
|
39
|
+
|
40
|
+
# EOF
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), %w[.. setup])
|
3
|
+
|
4
|
+
module TestLogging
|
5
|
+
module TestLayouts
|
6
|
+
|
7
|
+
class TestBasic < Test::Unit::TestCase
|
8
|
+
include LoggingTestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
@layout = Logging.layouts.basic({})
|
13
|
+
@levels = Logging::LEVELS
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_format
|
17
|
+
event = Logging::LogEvent.new( 'ArrayLogger', @levels['info'],
|
18
|
+
'log message', false)
|
19
|
+
assert_equal " INFO ArrayLogger : log message\n", @layout.format(event)
|
20
|
+
|
21
|
+
event.data = [1, 2, 3, 4]
|
22
|
+
assert_equal(" INFO ArrayLogger : <Array> #{[1,2,3,4]}\n",
|
23
|
+
@layout.format(event))
|
24
|
+
|
25
|
+
event.level = @levels['debug']
|
26
|
+
event.data = 'and another message'
|
27
|
+
log = "DEBUG ArrayLogger : and another message\n"
|
28
|
+
assert_equal log, @layout.format(event)
|
29
|
+
|
30
|
+
event.logger = 'Test'
|
31
|
+
event.level = @levels['fatal']
|
32
|
+
event.data = Exception.new
|
33
|
+
log = "FATAL Test : <Exception> Exception\n"
|
34
|
+
assert_equal log, @layout.format(event)
|
35
|
+
end
|
36
|
+
|
37
|
+
end # class TestBasic
|
38
|
+
|
39
|
+
end # module TestLayouts
|
40
|
+
end # module TestLogging
|
41
|
+
|
42
|
+
# EOF
|
@@ -0,0 +1,112 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), %w[.. setup])
|
3
|
+
|
4
|
+
module TestLogging
|
5
|
+
module TestLayouts
|
6
|
+
|
7
|
+
class TestJson < Test::Unit::TestCase
|
8
|
+
include LoggingTestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
@layout = Logging.layouts.json({})
|
13
|
+
@levels = Logging::LEVELS
|
14
|
+
@date_fmt = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
|
15
|
+
Thread.current[:name] = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_initializer
|
19
|
+
assert_raise(ArgumentError) {
|
20
|
+
Logging.layouts.parseable.new :style => :foo
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_format
|
25
|
+
fmt = %Q[\\{"timestamp":"#@date_fmt","level":"%s","logger":"%s","message":"%s"\\}\\n]
|
26
|
+
|
27
|
+
event = Logging::LogEvent.new('ArrayLogger', @levels['info'],
|
28
|
+
'log message', false)
|
29
|
+
rgxp = Regexp.new(sprintf(fmt, 'INFO', 'ArrayLogger', 'log message'))
|
30
|
+
assert_match rgxp, @layout.format(event)
|
31
|
+
|
32
|
+
event.data = [1, 2, 3, 4]
|
33
|
+
rgxp = Regexp.new(sprintf(fmt, 'INFO', 'ArrayLogger',
|
34
|
+
Regexp.escape("<Array> #{[1,2,3,4]}")))
|
35
|
+
assert_match rgxp, @layout.format(event)
|
36
|
+
|
37
|
+
event.level = @levels['debug']
|
38
|
+
event.data = 'and another message'
|
39
|
+
rgxp = Regexp.new(sprintf(fmt, 'DEBUG', 'ArrayLogger',
|
40
|
+
'and another message'))
|
41
|
+
assert_match rgxp, @layout.format(event)
|
42
|
+
|
43
|
+
event.logger = 'Test'
|
44
|
+
event.level = @levels['fatal']
|
45
|
+
event.data = Exception.new
|
46
|
+
rgxp = Regexp.new(sprintf(fmt, 'FATAL', 'Test', '<Exception> Exception'))
|
47
|
+
assert_match rgxp, @layout.format(event)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_items
|
51
|
+
assert_equal %w[timestamp level logger message], @layout.items
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_items_eq
|
55
|
+
event = Logging::LogEvent.new('TestLogger', @levels['info'],
|
56
|
+
['log message'], false)
|
57
|
+
|
58
|
+
@layout.items = %w[timestamp]
|
59
|
+
assert_equal %w[timestamp], @layout.items
|
60
|
+
assert_match %r/\{"timestamp":"#@date_fmt"\}\n/, @layout.format(event)
|
61
|
+
|
62
|
+
# 'foo' is not a recognized item
|
63
|
+
assert_raise(ArgumentError) {
|
64
|
+
@layout.items = %w[timestamp logger foo]
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_items_all
|
69
|
+
event = Logging::LogEvent.new('TestLogger', @levels['info'],
|
70
|
+
'log message', false)
|
71
|
+
event.file = 'test_file.rb'
|
72
|
+
event.line = 123
|
73
|
+
event.method = 'method_name'
|
74
|
+
|
75
|
+
@layout.items = %w[logger]
|
76
|
+
assert_equal %Q[{"logger":"TestLogger"}\n], @layout.format(event)
|
77
|
+
|
78
|
+
@layout.items = %w[file]
|
79
|
+
assert_equal %Q[{"file":"test_file.rb"}\n], @layout.format(event)
|
80
|
+
|
81
|
+
@layout.items = %w[level]
|
82
|
+
assert_equal %Q[{"level":"INFO"}\n], @layout.format(event)
|
83
|
+
|
84
|
+
@layout.items = %w[line]
|
85
|
+
assert_equal %Q[{"line":123}\n], @layout.format(event)
|
86
|
+
|
87
|
+
@layout.items = %w[message]
|
88
|
+
assert_equal %Q[{"message":"log message"}\n], @layout.format(event)
|
89
|
+
|
90
|
+
@layout.items = %w[method]
|
91
|
+
assert_equal %Q[{"method":"method_name"}\n], @layout.format(event)
|
92
|
+
|
93
|
+
@layout.items = %w[pid]
|
94
|
+
assert_match %r/\A\{"pid":\d+\}\n\z/, @layout.format(event)
|
95
|
+
|
96
|
+
@layout.items = %w[millis]
|
97
|
+
assert_match %r/\A\{"millis":\d+\}\n\z/, @layout.format(event)
|
98
|
+
|
99
|
+
@layout.items = %w[thread_id]
|
100
|
+
assert_match %r/\A\{"thread_id":-?\d+\}\n\z/, @layout.format(event)
|
101
|
+
|
102
|
+
@layout.items = %w[thread]
|
103
|
+
assert_equal %Q[{"thread":null}\n], @layout.format(event)
|
104
|
+
Thread.current[:name] = "Main"
|
105
|
+
assert_equal %Q[{"thread":"Main"}\n], @layout.format(event)
|
106
|
+
end
|
107
|
+
|
108
|
+
end # class TestJson
|
109
|
+
end # module TestLayouts
|
110
|
+
end # module TestLogging
|
111
|
+
|
112
|
+
# EOF
|
@@ -0,0 +1,198 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), %w[.. setup])
|
3
|
+
|
4
|
+
module TestLogging
|
5
|
+
module TestLayouts
|
6
|
+
|
7
|
+
class TestPattern < Test::Unit::TestCase
|
8
|
+
include LoggingTestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
@layout = Logging.layouts.pattern({})
|
13
|
+
@levels = Logging::LEVELS
|
14
|
+
@date_fmt = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
|
15
|
+
Thread.current[:name] = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_date_method
|
19
|
+
assert_nil @layout.date_method
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_date_method_eq
|
23
|
+
@layout.date_method = :to_f
|
24
|
+
assert_equal :to_f, @layout.date_method
|
25
|
+
assert_instance_of Float, @layout.format_date(Time.now)
|
26
|
+
|
27
|
+
@layout.date_method = 'usec'
|
28
|
+
assert_equal 'usec', @layout.date_method
|
29
|
+
assert_instance_of Fixnum, @layout.format_date(Time.now)
|
30
|
+
|
31
|
+
@layout.date_method = :to_s
|
32
|
+
assert_equal :to_s, @layout.date_method
|
33
|
+
assert_instance_of String, @layout.format_date(Time.now)
|
34
|
+
|
35
|
+
# now, even if we have defined a date_pattern, the date_method should
|
36
|
+
# supersede the date_pattern
|
37
|
+
@layout.date_pattern = '%Y'
|
38
|
+
|
39
|
+
@layout.date_method = 'usec'
|
40
|
+
assert_equal 'usec', @layout.date_method
|
41
|
+
assert_instance_of Fixnum, @layout.format_date(Time.now)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_date_pattern
|
45
|
+
assert_equal '%Y-%m-%d %H:%M:%S', @layout.date_pattern
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_date_pattern_eq
|
49
|
+
@layout.date_pattern = '%Y'
|
50
|
+
assert_equal '%Y', @layout.date_pattern
|
51
|
+
assert_match %r/\A\d{4}\z/, @layout.format_date(Time.now)
|
52
|
+
|
53
|
+
@layout.date_pattern = '%H:%M'
|
54
|
+
assert_equal '%H:%M', @layout.date_pattern
|
55
|
+
assert_match %r/\A\d{2}:\d{2}\z/, @layout.format_date(Time.now)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_format
|
59
|
+
fmt = '\[' + @date_fmt + '\] %s -- %s : %s\n'
|
60
|
+
|
61
|
+
event = Logging::LogEvent.new('ArrayLogger', @levels['info'],
|
62
|
+
'log message', false)
|
63
|
+
rgxp = Regexp.new(sprintf(fmt, 'INFO ', 'ArrayLogger', 'log message'))
|
64
|
+
assert_match rgxp, @layout.format(event)
|
65
|
+
|
66
|
+
event.data = [1, 2, 3, 4]
|
67
|
+
rgxp = Regexp.new(sprintf(fmt, 'INFO ', 'ArrayLogger',
|
68
|
+
Regexp.escape("<Array> #{[1,2,3,4]}")))
|
69
|
+
assert_match rgxp, @layout.format(event)
|
70
|
+
|
71
|
+
event.level = @levels['debug']
|
72
|
+
event.data = 'and another message'
|
73
|
+
rgxp = Regexp.new(
|
74
|
+
sprintf(fmt, 'DEBUG', 'ArrayLogger', 'and another message'))
|
75
|
+
assert_match rgxp, @layout.format(event)
|
76
|
+
|
77
|
+
event.logger = 'Test'
|
78
|
+
event.level = @levels['fatal']
|
79
|
+
event.data = Exception.new
|
80
|
+
rgxp = Regexp.new(
|
81
|
+
sprintf(fmt, 'FATAL', 'Test', '<Exception> Exception'))
|
82
|
+
assert_match rgxp, @layout.format(event)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_format_date
|
86
|
+
rgxp = Regexp.new @date_fmt
|
87
|
+
assert_match rgxp, @layout.format_date(Time.now)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_pattern
|
91
|
+
assert_equal "[%d] %-5l -- %c : %m\n", @layout.pattern
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_pattern_eq
|
95
|
+
event = Logging::LogEvent.new('TestLogger', @levels['info'],
|
96
|
+
['log message'], false)
|
97
|
+
|
98
|
+
@layout.pattern = '%d'
|
99
|
+
assert_equal '%d', @layout.pattern
|
100
|
+
assert_match Regexp.new(@date_fmt), @layout.format(event)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_pattern_all
|
104
|
+
event = Logging::LogEvent.new('TestLogger', @levels['info'],
|
105
|
+
'log message', false)
|
106
|
+
event.file = 'test_file.rb'
|
107
|
+
event.line = '123'
|
108
|
+
event.method = 'method_name'
|
109
|
+
|
110
|
+
@layout.pattern = '%c'
|
111
|
+
assert_equal 'TestLogger', @layout.format(event)
|
112
|
+
|
113
|
+
@layout.pattern = '%d'
|
114
|
+
assert_match Regexp.new(@date_fmt), @layout.format(event)
|
115
|
+
|
116
|
+
@layout.pattern = '%F'
|
117
|
+
assert_equal 'test_file.rb', @layout.format(event)
|
118
|
+
|
119
|
+
@layout.pattern = '%l'
|
120
|
+
assert_equal 'INFO', @layout.format(event)
|
121
|
+
|
122
|
+
@layout.pattern = '%L'
|
123
|
+
assert_equal '123', @layout.format(event)
|
124
|
+
|
125
|
+
@layout.pattern = '%m'
|
126
|
+
assert_equal 'log message', @layout.format(event)
|
127
|
+
|
128
|
+
@layout.pattern = '%M'
|
129
|
+
assert_equal 'method_name', @layout.format(event)
|
130
|
+
|
131
|
+
@layout.pattern = '%p'
|
132
|
+
assert_match %r/\A\d+\z/, @layout.format(event)
|
133
|
+
|
134
|
+
@layout.pattern = '%r'
|
135
|
+
assert_match %r/\A\d+\z/, @layout.format(event)
|
136
|
+
|
137
|
+
@layout.pattern = '%t'
|
138
|
+
assert_match %r/\A-?\d+\z/, @layout.format(event)
|
139
|
+
|
140
|
+
@layout.pattern = '%T'
|
141
|
+
assert_equal "", @layout.format(event)
|
142
|
+
Thread.current[:name] = "Main"
|
143
|
+
assert_equal "Main", @layout.format(event)
|
144
|
+
|
145
|
+
@layout.pattern = '%%'
|
146
|
+
assert_equal '%', @layout.format(event)
|
147
|
+
|
148
|
+
# 'z' is not a recognized format character
|
149
|
+
assert_raise(ArgumentError) {
|
150
|
+
@layout.pattern = '[%d] %% %c - %l %z blah'
|
151
|
+
}
|
152
|
+
assert_equal '%', @layout.format(event)
|
153
|
+
|
154
|
+
@layout.pattern = '%5l'
|
155
|
+
assert_equal ' INFO', @layout.format(event)
|
156
|
+
|
157
|
+
@layout.pattern = '%-5l'
|
158
|
+
assert_equal 'INFO ', @layout.format(event)
|
159
|
+
|
160
|
+
@layout.pattern = '%.1l, %c'
|
161
|
+
assert_equal 'I, TestLogger', @layout.format(event)
|
162
|
+
|
163
|
+
@layout.pattern = '%7.7m'
|
164
|
+
assert_equal 'log mes', @layout.format(event)
|
165
|
+
|
166
|
+
event.data = 'tim'
|
167
|
+
assert_equal ' tim', @layout.format(event)
|
168
|
+
|
169
|
+
@layout.pattern = '%-7.7m'
|
170
|
+
assert_equal 'tim ', @layout.format(event)
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_pattern_logger_name_precision
|
174
|
+
event = Logging::LogEvent.new('Foo', @levels['info'], 'message', false)
|
175
|
+
|
176
|
+
@layout.pattern = '%c{2}'
|
177
|
+
assert_equal 'Foo', @layout.format(event)
|
178
|
+
|
179
|
+
event.logger = 'Foo::Bar::Baz::Buz'
|
180
|
+
assert_equal 'Baz::Buz', @layout.format(event)
|
181
|
+
|
182
|
+
assert_raise(ArgumentError) {
|
183
|
+
@layout.pattern = '%c{0}'
|
184
|
+
}
|
185
|
+
|
186
|
+
@layout.pattern = '%c{foo}'
|
187
|
+
event.logger = 'Foo::Bar'
|
188
|
+
assert_equal 'Foo::Bar{foo}', @layout.format(event)
|
189
|
+
|
190
|
+
@layout.pattern = '%m{42}'
|
191
|
+
assert_equal 'message{42}', @layout.format(event)
|
192
|
+
end
|
193
|
+
|
194
|
+
end # class TestBasic
|
195
|
+
end # module TestLayouts
|
196
|
+
end # module TestLogging
|
197
|
+
|
198
|
+
# EOF
|