logsly 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/README.md +5 -2
- data/lib/logsly.rb +37 -24
- data/lib/logsly/outputs.rb +31 -15
- data/lib/logsly/version.rb +1 -1
- data/test/unit/logsly_tests.rb +43 -20
- data/test/unit/outputs_tests.rb +70 -13
- metadata +56 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7468a6fbc210718d790d9fa8f534da73614b2374
|
4
|
+
data.tar.gz: 2da77f41fce035a41d924f6cdfc5e18fc66b0287
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20dae74d64ad543d4726d00199388ef1c1a851c34e7fe66f784763fe812f30a2749f1d784a00e4ff8058da4a9c17e2e55c3add892d9b2b54b78a6e6c2de29cb6
|
7
|
+
data.tar.gz: 0335b12da4bf91cecdddef0b93907c6e5b592d0b0680fb88eb17e7ca3254143f84bfb02c5df4f95fcd4970c8a4d5739ae8058f5b9dfeb2388023f120926cdf72
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Logsly creates and delegates to a [Logging logger](https://github.com/TwP/loggin
|
|
32
32
|
## Settings
|
33
33
|
|
34
34
|
* `log_type`: custom string used to identify the type of the logger
|
35
|
-
* `level`: the level in use (default: `'
|
35
|
+
* `level`: the level in use (default: `'info'`)
|
36
36
|
* `outputs`: list of named outputs to log to (default: `[]`)
|
37
37
|
|
38
38
|
## Outputs
|
@@ -41,8 +41,9 @@ Logsly creates and delegates to a [Logging logger](https://github.com/TwP/loggin
|
|
41
41
|
|
42
42
|
```ruby
|
43
43
|
Logsly.stdout('my_stdout') do |logger|
|
44
|
+
level 'info' # (optional) if set, this level will be used instead of the logger's setting
|
44
45
|
pattern '[%d %-5l] : %m\n'
|
45
|
-
colors 'my_colors'
|
46
|
+
colors 'my_colors' # use the 'my_colors' color scheme
|
46
47
|
end
|
47
48
|
```
|
48
49
|
|
@@ -54,6 +55,7 @@ Define a named stdout output to use with your loggers. Pass a block to customiz
|
|
54
55
|
Logsly.file('my_file') do |logger|
|
55
56
|
path "development.log"
|
56
57
|
|
58
|
+
level 'debug' # log debug level when outputting to this file
|
57
59
|
pattern '[%d %-5l] : %m\n'
|
58
60
|
# don't use a color scheme
|
59
61
|
end
|
@@ -69,6 +71,7 @@ Logsly.syslog('my_syslog') do |logger|
|
|
69
71
|
facility Syslog::LOG_LOCAL0 # or whatever (default: `LOG_LOCAL0`)
|
70
72
|
log_opts Syslog::LOG_PID # or whatever (default: `(LOG_PID | LOG_CONS)`)
|
71
73
|
|
74
|
+
# no custom level set, just use the logger's setting
|
72
75
|
pattern '%m\n'
|
73
76
|
# don't use a color scheme
|
74
77
|
end
|
data/lib/logsly.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'logger'
|
1
2
|
require 'much-plugin'
|
2
3
|
require 'logsly/version'
|
3
4
|
require 'logsly/logging182'
|
@@ -7,6 +8,8 @@ require 'logsly/outputs'
|
|
7
8
|
module Logsly
|
8
9
|
include MuchPlugin
|
9
10
|
|
11
|
+
DEFAULT_LEVEL = 'info'.freeze
|
12
|
+
|
10
13
|
plugin_included do
|
11
14
|
include InstanceMethods
|
12
15
|
|
@@ -44,21 +47,27 @@ module Logsly
|
|
44
47
|
|
45
48
|
module InstanceMethods
|
46
49
|
|
47
|
-
attr_reader :log_type, :level, :outputs, :
|
50
|
+
attr_reader :log_type, :level, :outputs, :output_loggers
|
48
51
|
|
49
52
|
def initialize(log_type, opts = nil)
|
50
53
|
opts ||= {}
|
51
54
|
|
52
55
|
@log_type = log_type.to_s
|
53
|
-
@level = (opts[:level]
|
54
|
-
@outputs = [*(opts[:outputs] || opts['outputs'] || [])]
|
56
|
+
@level = (opts[:level] || opts['level'] || DEFAULT_LEVEL).to_s
|
57
|
+
@outputs = [*(opts[:outputs] || opts['outputs'] || [])].uniq
|
58
|
+
|
59
|
+
@output_loggers = @outputs.inject({}) do |hash, output_name|
|
60
|
+
unique_name = "#{self.class.name}-#{@log_type}-#{self.object_id}-#{output_name}"
|
61
|
+
logger = Logsly::Logging182.logger[unique_name]
|
62
|
+
output = Logsly.outputs(output_name)
|
63
|
+
output_data = output.data(self)
|
55
64
|
|
56
|
-
|
57
|
-
|
58
|
-
|
65
|
+
# prefer output-specific level; fall back to general level
|
66
|
+
logger.level = output_data ? output_data.level : @level
|
67
|
+
add_appender(logger, output.to_appender(output_data))
|
59
68
|
|
60
|
-
|
61
|
-
|
69
|
+
hash[output_name] = logger
|
70
|
+
hash
|
62
71
|
end
|
63
72
|
end
|
64
73
|
|
@@ -67,18 +76,28 @@ module Logsly
|
|
67
76
|
end
|
68
77
|
|
69
78
|
def file_path
|
70
|
-
@file_path ||= if (appender = get_file_appender)
|
79
|
+
@file_path ||= if (appender = get_file_appender(self.appenders))
|
71
80
|
appender.name if appender.respond_to?(:name)
|
72
81
|
end
|
73
82
|
end
|
74
83
|
|
75
|
-
# delegate all calls to the
|
84
|
+
# delegate all logger level method calls to the output loggers
|
76
85
|
|
77
|
-
|
78
|
-
|
86
|
+
::Logger::Severity.constants.each do |name|
|
87
|
+
define_method(name.downcase) do |*args, &block|
|
88
|
+
self.output_loggers.each do |_, logger|
|
89
|
+
logger.send(name.downcase, *args, &block)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
define_method("#{name.downcase}?") do |*args, &block|
|
93
|
+
self.output_loggers.inject(false) do |bool, (_, logger)|
|
94
|
+
bool || logger.send("#{name.downcase}?", *args, &block)
|
95
|
+
end
|
96
|
+
end
|
79
97
|
end
|
80
|
-
|
81
|
-
|
98
|
+
|
99
|
+
def appenders
|
100
|
+
@appenders ||= self.output_loggers.map{ |(_, l)| l.appenders }.flatten
|
82
101
|
end
|
83
102
|
|
84
103
|
def ==(other_logger)
|
@@ -97,18 +116,12 @@ module Logsly
|
|
97
116
|
|
98
117
|
private
|
99
118
|
|
100
|
-
def add_appender(appender)
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
def appender_added?(appender)
|
105
|
-
@logger.appenders.detect do |existing|
|
106
|
-
existing.kind_of?(appender.class) && existing.name == appender.name
|
107
|
-
end
|
119
|
+
def add_appender(output_logger, appender)
|
120
|
+
output_logger.add_appenders(appender) if appender
|
108
121
|
end
|
109
122
|
|
110
|
-
def get_file_appender
|
111
|
-
|
123
|
+
def get_file_appender(appenders)
|
124
|
+
self.appenders.detect{ |a| a.kind_of?(Logsly::Logging182::Appenders::File) }
|
112
125
|
end
|
113
126
|
|
114
127
|
end
|
data/lib/logsly/outputs.rb
CHANGED
@@ -4,11 +4,14 @@ require 'logsly/logging182'
|
|
4
4
|
module Logsly; end
|
5
5
|
module Logsly::Outputs
|
6
6
|
|
7
|
+
DEFAULT_PATTERN = '%m\n'.freeze # log the message only
|
8
|
+
|
7
9
|
## NULL
|
8
10
|
|
9
11
|
class Null
|
10
|
-
def
|
11
|
-
def to_layout(
|
12
|
+
def data(*args); nil; end
|
13
|
+
def to_layout(data); nil; end
|
14
|
+
def to_appender(data); nil; end
|
12
15
|
end
|
13
16
|
|
14
17
|
## BASE
|
@@ -21,17 +24,15 @@ module Logsly::Outputs
|
|
21
24
|
@build = build || Proc.new{}
|
22
25
|
end
|
23
26
|
|
24
|
-
def
|
25
|
-
|
26
|
-
self.colors_obj.run_build(*args)
|
27
|
-
self
|
27
|
+
def data(*args)
|
28
|
+
raise NotImplementedError
|
28
29
|
end
|
29
30
|
|
30
31
|
def to_layout(data)
|
31
32
|
Logsly::Logging182.layouts.pattern(data.to_pattern_opts)
|
32
33
|
end
|
33
34
|
|
34
|
-
def to_appender(
|
35
|
+
def to_appender(data)
|
35
36
|
raise NotImplementedError
|
36
37
|
end
|
37
38
|
|
@@ -40,8 +41,9 @@ module Logsly::Outputs
|
|
40
41
|
class BaseData
|
41
42
|
|
42
43
|
def initialize(*args, &build)
|
43
|
-
@pattern =
|
44
|
+
@pattern = DEFAULT_PATTERN
|
44
45
|
@colors = nil
|
46
|
+
@level = nil
|
45
47
|
|
46
48
|
@args = args
|
47
49
|
self.instance_exec(*@args, &(build || Proc.new{}))
|
@@ -57,6 +59,11 @@ module Logsly::Outputs
|
|
57
59
|
@colors
|
58
60
|
end
|
59
61
|
|
62
|
+
def level(value = nil)
|
63
|
+
@level = value if !value.nil?
|
64
|
+
@level
|
65
|
+
end
|
66
|
+
|
60
67
|
def to_pattern_opts
|
61
68
|
Hash.new.tap do |opts|
|
62
69
|
opts[:pattern] = self.pattern if self.pattern
|
@@ -79,8 +86,11 @@ module Logsly::Outputs
|
|
79
86
|
|
80
87
|
class Stdout < Base
|
81
88
|
|
82
|
-
def
|
83
|
-
|
89
|
+
def data(*args)
|
90
|
+
BaseData.new(*args, &self.build)
|
91
|
+
end
|
92
|
+
|
93
|
+
def to_appender(data)
|
84
94
|
Logsly::Logging182.appenders.stdout(:layout => self.to_layout(data))
|
85
95
|
end
|
86
96
|
|
@@ -90,8 +100,11 @@ module Logsly::Outputs
|
|
90
100
|
|
91
101
|
class File < Base
|
92
102
|
|
93
|
-
def
|
94
|
-
|
103
|
+
def data(*args)
|
104
|
+
FileData.new(*args, &self.build)
|
105
|
+
end
|
106
|
+
|
107
|
+
def to_appender(data)
|
95
108
|
Logsly::Logging182.appenders.file(data.path, :layout => self.to_layout(data))
|
96
109
|
end
|
97
110
|
|
@@ -110,10 +123,13 @@ module Logsly::Outputs
|
|
110
123
|
|
111
124
|
class Syslog < Base
|
112
125
|
|
113
|
-
def
|
126
|
+
def data(*args)
|
127
|
+
SyslogData.new(*args, &self.build)
|
128
|
+
end
|
129
|
+
|
130
|
+
def to_appender(data)
|
114
131
|
::Syslog.close if ::Syslog.opened?
|
115
132
|
|
116
|
-
data = SyslogData.new(*args, &self.build)
|
117
133
|
Logsly::Logging182.appenders.syslog(data.identity, {
|
118
134
|
:logopt => data.log_opts,
|
119
135
|
:facility => data.facility,
|
@@ -126,9 +142,9 @@ module Logsly::Outputs
|
|
126
142
|
class SyslogData < BaseData
|
127
143
|
|
128
144
|
def initialize(*args, &build)
|
129
|
-
super
|
130
145
|
@log_opts = (::Syslog::LOG_PID | ::Syslog::LOG_CONS)
|
131
146
|
@facility = ::Syslog::LOG_LOCAL0
|
147
|
+
super
|
132
148
|
end
|
133
149
|
|
134
150
|
def identity(value = nil)
|
data/lib/logsly/version.rb
CHANGED
data/test/unit/logsly_tests.rb
CHANGED
@@ -17,6 +17,10 @@ module Logsly
|
|
17
17
|
|
18
18
|
should have_imeths :reset, :colors, :stdout, :file, :syslog, :outputs
|
19
19
|
|
20
|
+
should "know its default level" do
|
21
|
+
assert_equal 'info', DEFAULT_LEVEL
|
22
|
+
end
|
23
|
+
|
20
24
|
should "return a NullColors obj when requesting a color scheme that isn't defined" do
|
21
25
|
assert_kind_of NullColors, Logsly.colors('not_defined_yet')
|
22
26
|
end
|
@@ -107,39 +111,45 @@ module Logsly
|
|
107
111
|
end
|
108
112
|
subject{ @logger }
|
109
113
|
|
110
|
-
should have_readers :log_type, :level, :outputs, :
|
114
|
+
should have_readers :log_type, :level, :outputs, :output_loggers
|
111
115
|
should have_imeths :mdc, :file_path
|
116
|
+
should have_imeths *::Logger::Severity.constants.map{ |n| n.downcase.to_sym }
|
117
|
+
should have_imeths *::Logger::Severity.constants.map{ |n| "#{n.downcase}?".to_sym }
|
112
118
|
|
113
119
|
should "know its log_type" do
|
114
120
|
assert_equal 'testy_log_logger', subject.log_type
|
115
121
|
end
|
116
122
|
|
117
123
|
should "know its default opt values" do
|
118
|
-
assert_equal
|
119
|
-
assert_equal [],
|
124
|
+
assert_equal DEFAULT_LEVEL, subject.level
|
125
|
+
assert_equal [], subject.outputs
|
120
126
|
end
|
121
127
|
|
122
128
|
should "allow overridding the default opt values" do
|
123
|
-
log = TestLogger.new(:testy_debug_logger,
|
129
|
+
log = TestLogger.new(:testy_debug_logger, {
|
130
|
+
:level => :debug,
|
131
|
+
:outputs => :stdout
|
132
|
+
})
|
124
133
|
assert_equal 'debug', log.level
|
125
134
|
assert_equal [:stdout], log.outputs
|
126
135
|
end
|
127
136
|
|
128
|
-
should "create a Logsly::Logging182::Logger" do
|
129
|
-
|
130
|
-
assert_kind_of Logsly::Logging182::Logger, subject.logger
|
131
|
-
end
|
137
|
+
should "create a Logsly::Logging182::Logger for each output" do
|
138
|
+
assert_empty subject.output_loggers
|
132
139
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
140
|
+
outputs = Factory.integer(3).times.map{ Factory.string }
|
141
|
+
log = TestLogger.new(:testy_log_logger, :outputs => outputs)
|
142
|
+
outputs.each do |output|
|
143
|
+
logger = log.output_loggers[output]
|
144
|
+
assert_kind_of Logsly::Logging182::Logger, logger
|
137
145
|
|
138
|
-
|
139
|
-
|
146
|
+
# set a unique name for each logger
|
147
|
+
exp = "#{log.class.name}-testy_log_logger-#{log.object_id}-#{output}"
|
148
|
+
assert_equal exp, logger.name
|
140
149
|
|
141
|
-
|
142
|
-
|
150
|
+
# default the level for each logger
|
151
|
+
assert_equal Logsly::Logging182::LEVELS[DEFAULT_LEVEL], logger.level
|
152
|
+
end
|
143
153
|
end
|
144
154
|
|
145
155
|
should "set mdc key/value pairs" do
|
@@ -159,37 +169,50 @@ module Logsly
|
|
159
169
|
|
160
170
|
class AppenderTests < UnitTests
|
161
171
|
setup do
|
162
|
-
Logsly.stdout
|
172
|
+
Logsly.stdout('my_stdout') do |logger|
|
173
|
+
level 'debug'
|
174
|
+
end
|
163
175
|
Logsly.file('my_file') do |logger|
|
164
176
|
path "log/development-#{logger.log_type}.log"
|
177
|
+
level 'debug'
|
165
178
|
end
|
166
179
|
Logsly.file('my_other_file') do |logger|
|
167
180
|
path "log/other-#{logger.log_type}.log"
|
168
181
|
end
|
169
182
|
Logsly.syslog('my_syslog') do |logger|
|
170
183
|
identity "my_syslog_logger-#{logger.log_type}"
|
184
|
+
level 'debug'
|
171
185
|
end
|
172
186
|
end
|
173
187
|
|
174
|
-
should "add a named stdout appender" do
|
188
|
+
should "add a named stdout appender and honor its level" do
|
175
189
|
log = TestLogger.new(:test, :outputs => 'my_stdout')
|
176
190
|
assert_includes_appender Logsly::Logging182::Appenders::Stdout, log
|
177
191
|
assert_nil log.file_path
|
192
|
+
|
193
|
+
exp = Logsly::Logging182::LEVELS['debug']
|
194
|
+
assert_equal exp, log.output_loggers['my_stdout'].level
|
178
195
|
end
|
179
196
|
|
180
|
-
should "add a named file appender" do
|
197
|
+
should "add a named file appender and honor its level" do
|
181
198
|
log = TestLogger.new(:test, :outputs => 'my_file')
|
182
199
|
filelog = extract_appender_from_logger(log, :file)
|
183
200
|
|
184
201
|
assert_includes_appender Logsly::Logging182::Appenders::File, log
|
185
202
|
assert_equal 'log/development-test.log', filelog.name
|
186
203
|
assert_equal 'log/development-test.log', log.file_path
|
204
|
+
|
205
|
+
exp = Logsly::Logging182::LEVELS['debug']
|
206
|
+
assert_equal exp, log.output_loggers['my_file'].level
|
187
207
|
end
|
188
208
|
|
189
|
-
should "add a named syslog appender" do
|
209
|
+
should "add a named syslog appender and honor its level" do
|
190
210
|
log = TestLogger.new(:test, :outputs => 'my_syslog')
|
191
211
|
assert_includes_appender Logsly::Logging182::Appenders::Syslog, log
|
192
212
|
assert_nil log.file_path
|
213
|
+
|
214
|
+
exp = Logsly::Logging182::LEVELS['debug']
|
215
|
+
assert_equal exp, log.output_loggers['my_syslog'].level
|
193
216
|
end
|
194
217
|
|
195
218
|
should "not add duplicate appenders" do
|
data/test/unit/outputs_tests.rb
CHANGED
@@ -8,6 +8,30 @@ module Logsly::Outputs
|
|
8
8
|
|
9
9
|
class UnitTests < Assert::Context
|
10
10
|
desc "Logsly::Outputs"
|
11
|
+
subject{ @out }
|
12
|
+
|
13
|
+
should "know its default pattern" do
|
14
|
+
assert_equal '%m\n', Logsly::Outputs::DEFAULT_PATTERN
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class NullTests < UnitTests
|
20
|
+
desc "Null"
|
21
|
+
setup do
|
22
|
+
@out = Null.new
|
23
|
+
end
|
24
|
+
|
25
|
+
should have_imeths :data, :to_layout, :to_appender
|
26
|
+
|
27
|
+
should "know its data" do
|
28
|
+
assert_nil subject.data
|
29
|
+
end
|
30
|
+
|
31
|
+
should "always return `nil` converting to a layout/appender" do
|
32
|
+
assert_nil subject.to_layout(Factory.string)
|
33
|
+
assert_nil subject.to_appender(Factory.string)
|
34
|
+
end
|
11
35
|
|
12
36
|
end
|
13
37
|
|
@@ -16,10 +40,9 @@ module Logsly::Outputs
|
|
16
40
|
setup do
|
17
41
|
@out = Base.new
|
18
42
|
end
|
19
|
-
subject{ @out }
|
20
43
|
|
21
44
|
should have_reader :build
|
22
|
-
should have_imeths :to_layout, :to_appender
|
45
|
+
should have_imeths :data, :to_layout, :to_appender
|
23
46
|
|
24
47
|
should "know its build" do
|
25
48
|
build_proc = Proc.new{}
|
@@ -28,9 +51,10 @@ module Logsly::Outputs
|
|
28
51
|
assert_same build_proc, out.build
|
29
52
|
end
|
30
53
|
|
31
|
-
should "expect `to_appender` to be defined by subclasses" do
|
54
|
+
should "expect `data` and `to_appender` to be defined by subclasses" do
|
55
|
+
assert_raises(NotImplementedError){ subject.data }
|
32
56
|
assert_raises NotImplementedError do
|
33
|
-
subject.to_appender
|
57
|
+
subject.to_appender(Factory.string)
|
34
58
|
end
|
35
59
|
end
|
36
60
|
|
@@ -79,21 +103,24 @@ module Logsly::Outputs
|
|
79
103
|
@data = BaseData.new(@arg) do |*args|
|
80
104
|
pattern args.first
|
81
105
|
colors 'a_color_scheme'
|
106
|
+
level 'info'
|
82
107
|
end
|
83
108
|
end
|
84
109
|
subject{ @data }
|
85
110
|
|
86
|
-
should have_imeths :pattern, :colors
|
111
|
+
should have_imeths :pattern, :colors, :level
|
87
112
|
|
88
113
|
should "know its defaults" do
|
89
114
|
data = BaseData.new
|
90
|
-
assert_equal
|
115
|
+
assert_equal DEFAULT_PATTERN, data.pattern
|
91
116
|
assert_nil data.colors
|
117
|
+
assert_nil data.level
|
92
118
|
end
|
93
119
|
|
94
120
|
should "instance exec its build with args" do
|
95
121
|
assert_equal '%d : %m\n', subject.pattern
|
96
122
|
assert_equal 'a_color_scheme', subject.colors
|
123
|
+
assert_equal 'info', subject.level
|
97
124
|
end
|
98
125
|
|
99
126
|
should "know its layout pattern opts hash" do
|
@@ -124,6 +151,7 @@ module Logsly::Outputs
|
|
124
151
|
@out = Stdout.new do |logger|
|
125
152
|
pattern logger.pattern
|
126
153
|
colors 'a_color_scheme'
|
154
|
+
level 'info'
|
127
155
|
end
|
128
156
|
end
|
129
157
|
subject{ @out }
|
@@ -132,13 +160,21 @@ module Logsly::Outputs
|
|
132
160
|
assert_kind_of Base, subject
|
133
161
|
end
|
134
162
|
|
163
|
+
should "know its data" do
|
164
|
+
data = subject.data(@logger)
|
165
|
+
assert_instance_of BaseData, data
|
166
|
+
assert_equal @logger.pattern, data.pattern
|
167
|
+
assert_equal 'a_color_scheme', data.colors
|
168
|
+
assert_equal 'info', data.level
|
169
|
+
end
|
170
|
+
|
135
171
|
should "build a Logsly::Logging182 stdout appender, passing args to the builds" do
|
136
|
-
appender = subject.to_appender
|
172
|
+
appender = subject.to_appender(subject.data(@logger))
|
137
173
|
|
138
174
|
assert_kind_of Logsly::Logging182::Appenders::Stdout, appender
|
139
175
|
assert_kind_of Logsly::Logging182::Layouts::Pattern, appender.layout
|
140
176
|
assert_kind_of Logsly::Logging182::ColorScheme, appender.layout.color_scheme
|
141
|
-
assert_equal
|
177
|
+
assert_equal @logger.pattern, appender.layout.pattern
|
142
178
|
end
|
143
179
|
|
144
180
|
end
|
@@ -160,6 +196,7 @@ module Logsly::Outputs
|
|
160
196
|
|
161
197
|
pattern logger.pattern
|
162
198
|
colors 'a_color_scheme'
|
199
|
+
level 'info'
|
163
200
|
end
|
164
201
|
end
|
165
202
|
subject{ @out }
|
@@ -168,14 +205,23 @@ module Logsly::Outputs
|
|
168
205
|
assert_kind_of Base, subject
|
169
206
|
end
|
170
207
|
|
208
|
+
should "know its data" do
|
209
|
+
data = subject.data(@logger)
|
210
|
+
assert_instance_of FileData, data
|
211
|
+
assert_equal @logger.file, data.path
|
212
|
+
assert_equal @logger.pattern, data.pattern
|
213
|
+
assert_equal 'a_color_scheme', data.colors
|
214
|
+
assert_equal 'info', data.level
|
215
|
+
end
|
216
|
+
|
171
217
|
should "build a Logsly::Logging182 file appender, passing args to the builds" do
|
172
|
-
appender = subject.to_appender
|
218
|
+
appender = subject.to_appender(subject.data(@logger))
|
173
219
|
|
174
220
|
assert_kind_of Logsly::Logging182::Appenders::File, appender
|
175
221
|
assert_kind_of Logsly::Logging182::Layouts::Pattern, appender.layout
|
176
222
|
assert_kind_of Logsly::Logging182::ColorScheme, appender.layout.color_scheme
|
177
|
-
assert_equal
|
178
|
-
assert_equal
|
223
|
+
assert_equal @logger.file, appender.name
|
224
|
+
assert_equal @logger.pattern, appender.layout.pattern
|
179
225
|
end
|
180
226
|
|
181
227
|
end
|
@@ -210,6 +256,7 @@ module Logsly::Outputs
|
|
210
256
|
|
211
257
|
pattern logger.pattern
|
212
258
|
colors 'a_color_scheme'
|
259
|
+
level 'info'
|
213
260
|
end
|
214
261
|
end
|
215
262
|
subject{ @out }
|
@@ -218,13 +265,23 @@ module Logsly::Outputs
|
|
218
265
|
assert_kind_of Base, subject
|
219
266
|
end
|
220
267
|
|
268
|
+
should "know its data" do
|
269
|
+
data = subject.data(@logger)
|
270
|
+
assert_instance_of SyslogData, data
|
271
|
+
assert_equal @logger.identity, data.identity
|
272
|
+
assert_equal @logger.facility, data.facility
|
273
|
+
assert_equal @logger.pattern, data.pattern
|
274
|
+
assert_equal 'a_color_scheme', data.colors
|
275
|
+
assert_equal 'info', data.level
|
276
|
+
end
|
277
|
+
|
221
278
|
should "build a Logsly::Logging182 syslog appender, passing args to the builds" do
|
222
|
-
appender = subject.to_appender
|
279
|
+
appender = subject.to_appender(subject.data(@logger))
|
223
280
|
|
224
281
|
assert_kind_of Logsly::Logging182::Appenders::Syslog, appender
|
225
282
|
assert_kind_of Logsly::Logging182::Layouts::Pattern, appender.layout
|
226
283
|
assert_kind_of Logsly::Logging182::ColorScheme, appender.layout.color_scheme
|
227
|
-
assert_equal
|
284
|
+
assert_equal @logger.pattern, appender.layout.pattern
|
228
285
|
end
|
229
286
|
|
230
287
|
end
|
metadata
CHANGED
@@ -1,81 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: logsly
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Kelly Redding
|
8
8
|
- Collin Redding
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2016-07-09 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: assert
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 2.16.1
|
21
|
-
type: :development
|
22
17
|
prerelease: false
|
23
|
-
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
27
22
|
version: 2.16.1
|
28
|
-
|
23
|
+
type: :development
|
24
|
+
version_requirements: *id001
|
25
|
+
- !ruby/object:Gem::Dependency
|
29
26
|
name: much-plugin
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 0.2.0
|
35
|
-
type: :runtime
|
36
27
|
prerelease: false
|
37
|
-
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
41
32
|
version: 0.2.0
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: little-plugger
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 1.1.4
|
49
33
|
type: :runtime
|
34
|
+
version_requirements: *id002
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: little-plugger
|
50
37
|
prerelease: false
|
51
|
-
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
38
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
55
42
|
version: 1.1.4
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: multi_json
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 1.12.1
|
63
43
|
type: :runtime
|
44
|
+
version_requirements: *id003
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: multi_json
|
64
47
|
prerelease: false
|
65
|
-
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
48
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ~>
|
51
|
+
- !ruby/object:Gem::Version
|
69
52
|
version: 1.12.1
|
53
|
+
type: :runtime
|
54
|
+
version_requirements: *id004
|
70
55
|
description: Create custom loggers.
|
71
|
-
email:
|
56
|
+
email:
|
72
57
|
- kelly@kellyredding.com
|
73
58
|
- collin.redding@me.com
|
74
59
|
executables: []
|
60
|
+
|
75
61
|
extensions: []
|
62
|
+
|
76
63
|
extra_rdoc_files: []
|
77
|
-
|
78
|
-
|
64
|
+
|
65
|
+
files:
|
66
|
+
- .gitignore
|
79
67
|
- Gemfile
|
80
68
|
- LICENSE
|
81
69
|
- README.md
|
@@ -122,30 +110,32 @@ files:
|
|
122
110
|
- test/unit/outputs_tests.rb
|
123
111
|
- tmp/.gitkeep
|
124
112
|
homepage: http://github.com/redding/logsly
|
125
|
-
licenses:
|
113
|
+
licenses:
|
126
114
|
- MIT
|
127
115
|
metadata: {}
|
116
|
+
|
128
117
|
post_install_message:
|
129
118
|
rdoc_options: []
|
130
|
-
|
119
|
+
|
120
|
+
require_paths:
|
131
121
|
- lib
|
132
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
-
|
135
|
-
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
version: '0'
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- &id005
|
125
|
+
- ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: "0"
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- *id005
|
142
131
|
requirements: []
|
132
|
+
|
143
133
|
rubyforge_project:
|
144
134
|
rubygems_version: 2.6.4
|
145
135
|
signing_key:
|
146
136
|
specification_version: 4
|
147
137
|
summary: Create custom loggers.
|
148
|
-
test_files:
|
138
|
+
test_files:
|
149
139
|
- test/helper.rb
|
150
140
|
- test/support/factory.rb
|
151
141
|
- test/support/logger.rb
|