loggability 0.15.0.pre20190714094638 → 0.18.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -106,6 +106,7 @@ describe Loggability::Logger do
106
106
  expect( logger.level ).to eq( :warn )
107
107
  end
108
108
 
109
+
109
110
  it "defaults to :debug level when $DEBUG is true" do
110
111
  begin
111
112
  $DEBUG = true
@@ -115,6 +116,7 @@ describe Loggability::Logger do
115
116
  end
116
117
  end
117
118
 
119
+
118
120
  it "allows its levels to be set with integers like Logger" do
119
121
  newlevel = Logger::DEBUG
120
122
  $stderr.puts "Setting newlevel to %p" % [ newlevel ]
@@ -122,11 +124,13 @@ describe Loggability::Logger do
122
124
  expect( logger.level ).to eq( :debug )
123
125
  end
124
126
 
127
+
125
128
  it "allows its levels to be set with Symbolic level names" do
126
129
  logger.level = :info
127
130
  expect( logger.level ).to eq( :info )
128
131
  end
129
132
 
133
+
130
134
  it "allows its levels to be set with Stringish level names" do
131
135
  logger.level = 'fatal'
132
136
  expect( logger.level ).to eq( :fatal )
@@ -141,12 +145,14 @@ describe Loggability::Logger do
141
145
  expect( logger.logdev.dev ).to be( $stderr )
142
146
  end
143
147
 
148
+
144
149
  it "can be told to log to a file" do
145
150
  tmpfile = Tempfile.new( 'loggability-device-spec' )
146
151
  logger.output_to( tmpfile.path )
147
152
  expect( logger.logdev.dev ).to be_a( File )
148
153
  end
149
154
 
155
+
150
156
  it "supports log-rotation arguments for logfiles" do
151
157
  tmpfile = Tempfile.new( 'loggability-device-spec' )
152
158
  logger.output_to( tmpfile.path, 5, 125000 )
@@ -156,16 +162,45 @@ describe Loggability::Logger do
156
162
  expect( logger.logdev.instance_variable_get(:@shift_size) ).to eq( 125000 )
157
163
  end
158
164
 
165
+
166
+ it "can be told to log to a file and delegate to ruby's built-in logger log device" do
167
+ logfile = double( "logfile.log" )
168
+ expect( Loggability::LogDevice ).to receive( :create ).
169
+ with( :file, 'log_file.log' ).
170
+ and_return( logfile )
171
+
172
+ logfile = Loggability::LogDevice.create( :file, 'log_file.log' )
173
+ expect( logger ).to receive( :output_to ).
174
+ with( logfile ).
175
+ and_return( nil )
176
+
177
+ logger.output_to( logfile )
178
+
179
+ expect( logger.logdev ).to be_a( Logger::LogDevice )
180
+ end
181
+
182
+
183
+ it "can be told to log to a custom log device type" do
184
+ logger.output_to( :http, 'https://logapi.example.com:41133/v1/logintake' )
185
+
186
+ device = logger.logdev
187
+
188
+ expect( device ).to be_a( Loggability::LogDevice::Http )
189
+ expect( device.endpoint.to_s ).to eq( 'https://logapi.example.com:41133/v1/logintake' )
190
+ end
191
+
192
+
159
193
  it "can be told to log to an Array" do
160
194
  logmessages = []
161
195
  logger.output_to( logmessages )
162
- expect( logger.logdev ).to be_a( Loggability::Logger::AppendingLogDevice )
196
+ expect( logger.logdev ).to be_a( Loggability::LogDevice::Appending )
163
197
  logger.level = :debug
164
198
  logger.info( "Something happened." )
165
199
  expect( logmessages.size ).to eq( 1 )
166
200
  expect( logmessages.first ).to match( /something happened/i )
167
201
  end
168
202
 
203
+
169
204
  it "doesn't re-wrap a Logger::LogDevice" do
170
205
  tmpfile = Tempfile.new( 'loggability-device-spec' )
171
206
  logger.output_to( tmpfile.path, 5, 125000 )
@@ -176,7 +211,8 @@ describe Loggability::Logger do
176
211
  expect( logger.logdev ).to be( original_logdev )
177
212
  end
178
213
 
179
- it "doesn't re-wrap an AppendingLogDevice" do
214
+
215
+ it "doesn't re-wrap an Appending log device" do
180
216
  log_array = []
181
217
  logger.output_to( log_array )
182
218
  logger.output_to( logger.logdev )
@@ -193,11 +229,13 @@ describe Loggability::Logger do
193
229
  expect( logger.formatter ).to be_a( Loggability::Formatter::Default )
194
230
  end
195
231
 
232
+
196
233
  it "can be told to use the default formatter explicitly" do
197
234
  logger.format_as( :default )
198
235
  expect( logger.formatter ).to be_a( Loggability::Formatter::Default )
199
236
  end
200
237
 
238
+
201
239
  it "can be told to use a block as a formatter" do
202
240
  logger.format_with do |severity, datetime, progname, msg|
203
241
  original_formatter.call(severity, datetime, progname, msg.dump)
@@ -206,11 +244,13 @@ describe Loggability::Logger do
206
244
  expect( logger.formatter ).to be_a( Proc )
207
245
  end
208
246
 
247
+
209
248
  it "can be told to use the HTML formatter" do
210
249
  logger.format_as( :html )
211
250
  expect( logger.formatter ).to be_a( Loggability::Formatter::HTML )
212
251
  end
213
252
 
253
+
214
254
  it "supports formatting with ::Logger::Formatter, too" do
215
255
  output = []
216
256
  logger.output_to( output )
@@ -244,6 +284,7 @@ describe Loggability::Logger do
244
284
  expect( messages.first ).to match( expected_format )
245
285
  end
246
286
 
287
+
247
288
  it "has a terse inspection format" do
248
289
  object = Object.new
249
290
  expect(
@@ -23,18 +23,6 @@ describe Loggability do
23
23
  end
24
24
 
25
25
 
26
- describe "version methods" do
27
- it "returns a version string if asked" do
28
- expect( described_class.version_string ).to match( /\w+ [\d.]+/ )
29
- end
30
-
31
- it "returns a version string with a build number if asked" do
32
- expect( described_class.version_string(true) ).
33
- to match(/\w+ [\d.]+ \(build [[:xdigit:]]+\)/)
34
- end
35
- end
36
-
37
-
38
26
  context "installed in a class as a log host" do
39
27
 
40
28
  before( :each ) do
@@ -173,6 +161,12 @@ describe Loggability do
173
161
  expect( Loggability[loghost].logdev.dev ).to be( $stdout )
174
162
  end
175
163
 
164
+ it "can propagate an outputter with arguments to every loghost" do
165
+ Loggability.output_to( :http, 'http://localhost:12771/v1/logs' )
166
+ expect( Loggability[loghost].logdev ).to be_a( Loggability::LogDevice )
167
+ expect( Loggability[loghost].logdev.endpoint ).to eq( URI('http://localhost:12771/v1/logs') )
168
+ end
169
+
176
170
  it "can propagate a formatter to every loghost" do
177
171
  Loggability.format_with( :color )
178
172
  expect( Loggability[loghost].formatter ).to be_a( Loggability::Formatter::Color )
@@ -378,6 +372,13 @@ describe Loggability do
378
372
  expect( result ).to eq([ 'info', 'html', '/usr/local/www/htdocs/log.html' ])
379
373
  end
380
374
 
375
+ it 'can parse a logging confi spec with a severity, a http service name with its api key' do
376
+ result = Loggability.parse_config_spec('warn datadog[datadog_api_key]: (Color)')
377
+ expect( result[0] ).to eq( 'warn' )
378
+ expect( result[1] ).to eq( 'Color' )
379
+ expect( result[2].first ).to be_instance_of( Loggability::LogDevice::Datadog )
380
+ end
381
+
381
382
  it "can configure loghosts via its ::configure method" do
382
383
  config = {'class1' => 'debug (html)', 'class2' => 'error spec-error.log'}
383
384
  Loggability.configure( config )
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0.pre20190714094638
4
+ version: 0.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIENDCCApygAwIBAgIBATANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
14
- REM9RmFlcmllTVVEL0RDPW9yZzAeFw0xODExMjAxODI5NTlaFw0xOTExMjAxODI5
15
- NTlaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
13
+ MIID+DCCAmCgAwIBAgIBAzANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
14
+ REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMDEyMjQyMDU1MjlaFw0yMTEyMjQyMDU1
15
+ MjlaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
16
16
  hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
17
17
  L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZxkSUuWcP/sFhDXL1lWUuIl
18
18
  M4uHbGCRmOshDrF4dgnBeOvkHr1fIhPlJm5FO+Vew8tSQmlDsosxLUx+VB7DrVFO
@@ -21,77 +21,34 @@ cert_chain:
21
21
  vQ66lts4alKC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0GA1UdDgQWBBRyjf55EbrHagiRLqt5YAd3yb8k4DANBgkqhkiG
26
+ 9w0BAQsFAAOCAYEAMYegZanJi8zq7QKPT7wqXefX4C88I5JWeBHR3PvvWK0CwyMV
27
+ peyiu5I13w/lYX+HUZjE4qsSpJMJFXWl4WZCOo+AMprOcf0PxfuJpxCej5D4tavf
28
+ vRfhahSw7XJrcZih/3J+/UgoH7R05MJ+8LTcy3HGrB3a0vTafjm8OY7Xpa0LJDoN
29
+ JDqxK321VIHyTibbKeA1hWSE6ljlQDvFbTqiCj3Ulp1jTv3TOlvRl8fqcfhxUJI0
30
+ +5Q82jJODjEN+GaWs0V+NlrbU94cXwS2PH5dXogftB5YYA5Ex8A0ikZ73xns4Hdo
31
+ XxdLdd92F5ovxA23j/rKe/IDwqr6FpDkU3nPXH/Qp0TVGv9zZnVJc/Z6ChkuWj8z
32
+ pW7JAyyiiHZgKKDReDrA2LA7Zs3o/7KA6UtUH0FHf8LYhcK+pfHk6RtjRe65ffw+
33
+ MCh97sQ/Z/MOusb5+QddBmB+k8EicXyGNl4b5L4XpL7fIQu+Y96TB3JEJlShxFD9
34
+ k9FjI4d9EP54gS/4
36
35
  -----END CERTIFICATE-----
37
- date: 2019-07-14 00:00:00.000000000 Z
36
+ date: 2020-12-28 00:00:00.000000000 Z
38
37
  dependencies:
39
38
  - !ruby/object:Gem::Dependency
40
- name: hoe-mercurial
39
+ name: rake-deveiate
41
40
  requirement: !ruby/object:Gem::Requirement
42
41
  requirements:
43
42
  - - "~>"
44
43
  - !ruby/object:Gem::Version
45
- version: '1.4'
46
- type: :development
47
- prerelease: false
48
- version_requirements: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '1.4'
53
- - !ruby/object:Gem::Dependency
54
- name: hoe-deveiate
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '0.10'
60
- type: :development
61
- prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '0.10'
67
- - !ruby/object:Gem::Dependency
68
- name: hoe-highline
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: '0.2'
74
- type: :development
75
- prerelease: false
76
- version_requirements: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - "~>"
79
- - !ruby/object:Gem::Version
80
- version: '0.2'
81
- - !ruby/object:Gem::Dependency
82
- name: hoe-bundler
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '1.2'
44
+ version: '0.7'
88
45
  type: :development
89
46
  prerelease: false
90
47
  version_requirements: !ruby/object:Gem::Requirement
91
48
  requirements:
92
49
  - - "~>"
93
50
  - !ruby/object:Gem::Version
94
- version: '1.2'
51
+ version: '0.7'
95
52
  - !ruby/object:Gem::Dependency
96
53
  name: simplecov
97
54
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +69,14 @@ dependencies:
112
69
  requirements:
113
70
  - - "~>"
114
71
  - !ruby/object:Gem::Version
115
- version: '3.1'
72
+ version: '4.0'
116
73
  type: :development
117
74
  prerelease: false
118
75
  version_requirements: !ruby/object:Gem::Requirement
119
76
  requirements:
120
77
  - - "~>"
121
78
  - !ruby/object:Gem::Version
122
- version: '3.1'
79
+ version: '4.0'
123
80
  - !ruby/object:Gem::Dependency
124
81
  name: timecop
125
82
  requirement: !ruby/object:Gem::Requirement
@@ -135,65 +92,44 @@ dependencies:
135
92
  - !ruby/object:Gem::Version
136
93
  version: '0.9'
137
94
  - !ruby/object:Gem::Dependency
138
- name: rdoc
95
+ name: rdoc-generator-fivefish
139
96
  requirement: !ruby/object:Gem::Requirement
140
97
  requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- version: '4.0'
144
- - - "<"
98
+ - - "~>"
145
99
  - !ruby/object:Gem::Version
146
- version: '7'
100
+ version: '0.4'
147
101
  type: :development
148
102
  prerelease: false
149
103
  version_requirements: !ruby/object:Gem::Requirement
150
104
  requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: '4.0'
154
- - - "<"
105
+ - - "~>"
155
106
  - !ruby/object:Gem::Version
156
- version: '7'
107
+ version: '0.4'
157
108
  - !ruby/object:Gem::Dependency
158
- name: hoe
109
+ name: concurrent-ruby
159
110
  requirement: !ruby/object:Gem::Requirement
160
111
  requirements:
161
112
  - - "~>"
162
113
  - !ruby/object:Gem::Version
163
- version: '3.18'
114
+ version: '1.1'
164
115
  type: :development
165
116
  prerelease: false
166
117
  version_requirements: !ruby/object:Gem::Requirement
167
118
  requirements:
168
119
  - - "~>"
169
120
  - !ruby/object:Gem::Version
170
- version: '3.18'
171
- description: "A composable logging system built on the standard Logger library.\n\nYou
172
- can add Loggability to large libraries and systems, then hook everything\nup later
173
- when you know where you want logs to be written, at what level of\nseverity, and
174
- in which format.\n\nAn example:\n\n # Load a bunch of libraries that use Loggability\n
175
- \ require 'strelka'\n require 'inversion'\n require 'treequel'\n require
176
- 'loggability'\n \n # Set up our own library\n module MyProject\n extend
177
- Loggability\n log_as :my_project\n \n class Server\n extend
178
- Loggability\n log_to :my_project\n \n def initialize\n
179
- \ self.log.debug \"Listening.\"\n end\n end\n \n
180
- \ end\n \n # Now tell everything that's using Loggability to log to an HTML\n
181
- \ # log file at INFO level\n Loggability.write_to( '/usr/local/www/htdocs/log.html'
182
- )\n Loggability.format_as( :html )\n Loggability.level = :info"
121
+ version: '1.1'
122
+ description: A composable logging system built on the standard Logger library.
183
123
  email:
184
- - ged@FaerieMUD.org
124
+ - ged@faeriemud.org
185
125
  executables: []
186
126
  extensions: []
187
- extra_rdoc_files:
188
- - History.rdoc
189
- - Manifest.txt
190
- - README.rdoc
127
+ extra_rdoc_files: []
191
128
  files:
192
129
  - ".simplecov"
193
- - ChangeLog
194
130
  - History.rdoc
195
131
  - Manifest.txt
196
- - README.rdoc
132
+ - README.md
197
133
  - Rakefile
198
134
  - lib/loggability.rb
199
135
  - lib/loggability/constants.rb
@@ -201,6 +137,12 @@ files:
201
137
  - lib/loggability/formatter/color.rb
202
138
  - lib/loggability/formatter/default.rb
203
139
  - lib/loggability/formatter/html.rb
140
+ - lib/loggability/formatter/structured.rb
141
+ - lib/loggability/log_device.rb
142
+ - lib/loggability/log_device/appending.rb
143
+ - lib/loggability/log_device/datadog.rb
144
+ - lib/loggability/log_device/file.rb
145
+ - lib/loggability/log_device/http.rb
204
146
  - lib/loggability/logclient.rb
205
147
  - lib/loggability/logger.rb
206
148
  - lib/loggability/loghost.rb
@@ -208,36 +150,48 @@ files:
208
150
  - lib/loggability/spechelpers.rb
209
151
  - spec/helpers.rb
210
152
  - spec/loggability/formatter/color_spec.rb
153
+ - spec/loggability/formatter/default_spec.rb
211
154
  - spec/loggability/formatter/html_spec.rb
155
+ - spec/loggability/formatter/structured_spec.rb
212
156
  - spec/loggability/formatter_spec.rb
157
+ - spec/loggability/log_device/appending_spec.rb
158
+ - spec/loggability/log_device/datadog_spec.rb
159
+ - spec/loggability/log_device/file_spec.rb
160
+ - spec/loggability/log_device/http_spec.rb
213
161
  - spec/loggability/logger_spec.rb
214
162
  - spec/loggability/loghost_spec.rb
215
163
  - spec/loggability/override_spec.rb
216
164
  - spec/loggability/spechelpers_spec.rb
217
165
  - spec/loggability_spec.rb
218
- homepage: http://deveiate.org/projects/loggability
166
+ homepage: https://hg.sr.ht/~ged/Loggability
219
167
  licenses:
220
168
  - BSD-3-Clause
221
- metadata: {}
222
- post_install_message:
223
- rdoc_options:
224
- - "--main"
225
- - README.rdoc
169
+ metadata:
170
+ homepage_uri: https://hg.sr.ht/~ged/Loggability
171
+ documentation_uri: https://deveiate.org/code/loggability
172
+ changelog_uri: https://deveiate.org/code/loggability/History_md.html
173
+ source_uri: https://hg.sr.ht/~ged/Loggability/browse
174
+ bug_tracker_uri: https://todo.sr.ht/~ged/Loggability/browse
175
+ post_install_message:
176
+ rdoc_options: []
226
177
  require_paths:
227
178
  - lib
228
179
  required_ruby_version: !ruby/object:Gem::Requirement
229
180
  requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '2.5'
230
184
  - - ">="
231
185
  - !ruby/object:Gem::Version
232
- version: 1.9.3
186
+ version: '3.0'
233
187
  required_rubygems_version: !ruby/object:Gem::Requirement
234
188
  requirements:
235
- - - ">"
189
+ - - ">="
236
190
  - !ruby/object:Gem::Version
237
- version: 1.3.1
191
+ version: '0'
238
192
  requirements: []
239
- rubygems_version: 3.0.3
240
- signing_key:
193
+ rubygems_version: 3.2.3
194
+ signing_key:
241
195
  specification_version: 4
242
- summary: A composable logging system built on the standard Logger library
196
+ summary: A composable logging system built on the standard Logger library.
243
197
  test_files: []