loggability 0.14.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/History.rdoc +55 -0
  5. data/Manifest.txt +15 -4
  6. data/{README.rdoc → README.md} +78 -71
  7. data/Rakefile +5 -77
  8. data/lib/loggability.rb +19 -27
  9. data/lib/loggability/constants.rb +2 -2
  10. data/lib/loggability/formatter.rb +13 -67
  11. data/lib/loggability/formatter/color.rb +2 -2
  12. data/lib/loggability/formatter/default.rb +69 -6
  13. data/lib/loggability/formatter/html.rb +5 -5
  14. data/lib/loggability/formatter/structured.rb +35 -0
  15. data/lib/loggability/log_device.rb +86 -0
  16. data/lib/loggability/log_device/appending.rb +34 -0
  17. data/lib/loggability/log_device/datadog.rb +90 -0
  18. data/lib/loggability/log_device/file.rb +37 -0
  19. data/lib/loggability/log_device/http.rb +310 -0
  20. data/lib/loggability/logclient.rb +2 -1
  21. data/lib/loggability/logger.rb +45 -42
  22. data/lib/loggability/loghost.rb +2 -1
  23. data/lib/loggability/override.rb +2 -1
  24. data/lib/loggability/spechelpers.rb +1 -1
  25. data/spec/helpers.rb +6 -12
  26. data/spec/loggability/formatter/color_spec.rb +3 -7
  27. data/spec/loggability/formatter/default_spec.rb +50 -0
  28. data/spec/loggability/formatter/html_spec.rb +7 -7
  29. data/spec/loggability/formatter/structured_spec.rb +61 -0
  30. data/spec/loggability/formatter_spec.rb +42 -29
  31. data/spec/loggability/log_device/appending_spec.rb +27 -0
  32. data/spec/loggability/log_device/datadog_spec.rb +67 -0
  33. data/spec/loggability/log_device/file_spec.rb +27 -0
  34. data/spec/loggability/log_device/http_spec.rb +217 -0
  35. data/spec/loggability/logger_spec.rb +46 -5
  36. data/spec/loggability/loghost_spec.rb +3 -1
  37. data/spec/loggability/override_spec.rb +18 -5
  38. data/spec/loggability/spechelpers_spec.rb +3 -4
  39. data/spec/loggability_spec.rb +16 -13
  40. metadata +77 -105
  41. metadata.gz.sig +0 -0
  42. data/ChangeLog +0 -621
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4c536cf9f22b05e0acc0b3cb3e1f4202d19ab2c2
4
- data.tar.gz: 5262aca5aedb923da7883b756a1d0b6c664f13ab
2
+ SHA256:
3
+ metadata.gz: 5c0f3a12e9663d82cb709b0bf7f5aea24f9a49dba2435f5c63e289b7c731aa3e
4
+ data.tar.gz: cf7da9a50c5890505b96d2c1609f487a6ddb8c73c7deed602eb7508174613de2
5
5
  SHA512:
6
- metadata.gz: a53a0d4ea43fd572540705175b95e8bd1f797ebbc9059df328b17fdaf72fe76c8e2077bd47f729c02e430234872eeb234c6ec7d2c65466693af375d50dee05e0
7
- data.tar.gz: 920507dfb7ef2dff0105baae0d0da205e59e5e705bf5da5cb3149e17eabd80fffde576c9bf63a79cdb633a989d0d73f0bbebd82f637284b35c88690240058dd7
6
+ metadata.gz: e18c0c2891d2b0094dafa8b50b9b7d7ed8ba655e3f2f88105a279a655319041e39231417d0041eed2b29bed8b7fa956097f4d5f330a3a62122efd4de5d8d5435
7
+ data.tar.gz: b9a3fc6f3181e3e63d00d85709598601c3e266e19f471fb0456f7169c2acc2ea350235e480ce8adbbb16b713e234acfe6f9f76d951c4231e3847a48f6149419f
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,58 @@
1
+ = Release History for loggability
2
+
3
+ ---
4
+ == v0.18.0 [2020-12-24] Michael Granger <ged@faeriemud.org>
5
+
6
+ Improvements:
7
+
8
+ - Add memory management to the http log device
9
+ - Add a dead-simple log server example
10
+ - Update for Ruby 3, add my updated gem cert
11
+
12
+ Thanks again to Mahmood Khan <mkhan1484@gmail.com> for the patch.
13
+
14
+
15
+ == v0.17.0 [2020-02-27] Michael Granger <ged@faeriemud.org>
16
+
17
+ Bugfixes:
18
+
19
+ - Fix the construction of the client in the http log device
20
+
21
+ Improvements:
22
+
23
+ - Add support for log devices to the aggregate #output_to
24
+
25
+
26
+
27
+ == v0.16.0 [2020-02-24] Michael Granger <ged@faeriemud.org>
28
+
29
+ Improvements:
30
+
31
+ - Expose a "log device" API and add the ability to write to multiple devices
32
+ - Add a device for logging to an HTTP service
33
+
34
+ Thanks to Mahmood Khan <mkhan1484@gmail.com> for the patch.
35
+
36
+
37
+ == v0.15.1 [2020-01-09] Michael Granger <ged@faeriemud.org>
38
+
39
+ Bugfixes:
40
+
41
+ - Change the spec to require Ruby 2.5 or greater. This was because
42
+ of the use methods that are only public in newer versions.
43
+
44
+
45
+ == v0.15.0 [2020-01-08] Michael Granger <ged@faeriemud.org>
46
+
47
+ (Yanked)
48
+
49
+ Enhancements:
50
+
51
+ - Make literal strings frozen by default
52
+ - Add a structured log formatter.
53
+ - Add fixes for Ruby 2.6 and 2.7
54
+
55
+
1
56
  == v0.14.0 [2017-01-30] Michael Granger <ged@FaerieMUD.org>
2
57
 
3
58
  Enhancements:
@@ -1,26 +1,37 @@
1
1
  .simplecov
2
- ChangeLog
3
2
  History.rdoc
4
- Manifest.txt
5
- README.rdoc
6
- Rakefile
7
3
  lib/loggability.rb
8
4
  lib/loggability/constants.rb
9
5
  lib/loggability/formatter.rb
10
6
  lib/loggability/formatter/color.rb
11
7
  lib/loggability/formatter/default.rb
12
8
  lib/loggability/formatter/html.rb
9
+ lib/loggability/formatter/structured.rb
13
10
  lib/loggability/logclient.rb
14
11
  lib/loggability/logger.rb
15
12
  lib/loggability/loghost.rb
13
+ lib/loggability/log_device.rb
14
+ lib/loggability/log_device/appending.rb
15
+ lib/loggability/log_device/datadog.rb
16
+ lib/loggability/log_device/file.rb
17
+ lib/loggability/log_device/http.rb
16
18
  lib/loggability/override.rb
17
19
  lib/loggability/spechelpers.rb
20
+ Manifest.txt
21
+ Rakefile
22
+ README.md
18
23
  spec/helpers.rb
19
24
  spec/loggability/formatter/color_spec.rb
25
+ spec/loggability/formatter/default_spec.rb
20
26
  spec/loggability/formatter/html_spec.rb
27
+ spec/loggability/formatter/structured_spec.rb
21
28
  spec/loggability/formatter_spec.rb
22
29
  spec/loggability/logger_spec.rb
23
30
  spec/loggability/loghost_spec.rb
31
+ spec/loggability/log_device/appending_spec.rb
32
+ spec/loggability/log_device/datadog_spec.rb
33
+ spec/loggability/log_device/file_spec.rb
34
+ spec/loggability/log_device/http_spec.rb
24
35
  spec/loggability/override_spec.rb
25
36
  spec/loggability/spechelpers_spec.rb
26
37
  spec/loggability_spec.rb
@@ -1,12 +1,19 @@
1
- = loggability
1
+ # loggability
2
2
 
3
- home :: http://deveiate.org/projects/loggability
4
- code :: http://bitbucket.org/ged/loggability
5
- docs :: http://deveiate.org/code/loggability
6
- github :: http://github.com/ged/loggability
3
+ home
4
+ : https://hg.sr.ht/~ged/Loggability
7
5
 
6
+ code
7
+ : https://hg.sr.ht/~ged/Loggability/browse
8
8
 
9
- == Description
9
+ docs
10
+ : https://deveiate.org/code/loggability
11
+
12
+ github
13
+ : https://github.com/ged/loggability
14
+
15
+
16
+ ## Description
10
17
 
11
18
  A composable logging system built on the standard Logger library.
12
19
 
@@ -21,23 +28,23 @@ An example:
21
28
  require 'inversion'
22
29
  require 'treequel'
23
30
  require 'loggability'
24
-
31
+
25
32
  # Set up our own library
26
33
  module MyProject
27
34
  extend Loggability
28
35
  log_as :my_project
29
-
36
+
30
37
  class Server
31
38
  extend Loggability
32
39
  log_to :my_project
33
-
40
+
34
41
  def initialize
35
42
  self.log.debug "Listening."
36
43
  end
37
44
  end
38
-
45
+
39
46
  end
40
-
47
+
41
48
  # Now tell everything that's using Loggability to log to an HTML
42
49
  # log file at INFO level
43
50
  Loggability.write_to( '/usr/local/www/htdocs/log.html' )
@@ -45,30 +52,30 @@ An example:
45
52
  Loggability.level = :info
46
53
 
47
54
 
48
- == Prerequisites
55
+ ## Prerequisites
49
56
 
50
- * Ruby 1.9.3 or better, Rubinius 2.0 or better
57
+ * Ruby 2.4+
51
58
 
52
59
  It will probably work under any other interpreter in which Logger works, but
53
60
  it's only tested in the above.
54
61
 
55
62
 
56
- == Installation
63
+ ## Installation
57
64
 
58
65
  $ gem install loggability
59
66
 
60
67
 
61
- == Usage
68
+ ## Usage
62
69
 
63
- Loggability is split up into two parts: {log hosts}[rdoc-ref:Loggability::LogHost]
64
- and {log clients}[rdoc-ref:Loggability::LogClient]. A <b>log
70
+ Loggability is split up into two parts: [log hosts](rdoc-ref:Loggability::LogHost)
71
+ and [log clients](rdoc-ref:Loggability::LogClient). A <b>log
65
72
  host</b> is an object that contains a Logger instance that will be used to
66
73
  log stuff. A <b>log client</b> is an object that will write logging messages to a
67
74
  particular <b>log host</b>'s Logger.
68
75
 
69
76
  Both parts require that you extend the object with Loggability.
70
77
 
71
- === Setting Up A 'Log Host'
78
+ ### Setting Up A 'Log Host'
72
79
 
73
80
  To install a Logger into an object, you use the +log_as+ declaration with a
74
81
  Symbol that will be used as the key for the object's Logger:
@@ -116,10 +123,10 @@ or use a few new convenience methods for changing the logging level:
116
123
  log_messages = []
117
124
  MyProject.logger.output_to( log_messages )
118
125
 
119
- ...{and more}[rdoc-ref:Loggability::Logger].
126
+ ...[and more](rdoc-ref:Loggability::Logger).
120
127
 
121
128
 
122
- === Setting Up A 'Log Client'
129
+ ### Setting Up A 'Log Client'
123
130
 
124
131
  To add an object that will log to your log host, after you <tt>extend Loggability</tt>,
125
132
  use the +log_to+ declaration to hook up the object (and instances of the object if
@@ -153,7 +160,7 @@ You can also use the <b>log host</b> itself as the argument to +log_to+:
153
160
  end
154
161
 
155
162
 
156
- === Aggregate Logging
163
+ ### Aggregate Logging
157
164
 
158
165
  If you have several <b>log hosts</b>, and you want to affect them all simultaneously,
159
166
  you can do that using the aggregate functions of Loggability. They're the same as the
@@ -161,15 +168,15 @@ methods on Loggability::Logger:
161
168
 
162
169
  # Set all logs to log at INFO level
163
170
  Loggability.level = :info
164
-
171
+
165
172
  # Write HTML logs
166
173
  Loggability.format_with( :html )
167
-
174
+
168
175
  # Log everything to the same logfile
169
176
  Loggability.output_to( "/tmp/my_project_log.html" )
170
177
 
171
178
 
172
- === Temporarily Overriding Logging Behavior
179
+ ### Temporarily Overriding Logging Behavior
173
180
 
174
181
  Sometimes you want to log one particular chunk of code at a different
175
182
  level, or to a different destination, and then restore everything back
@@ -187,7 +194,7 @@ Loggability has a few ways of doing that:
187
194
  Loggability.outputting_to( logs ) do
188
195
  ...
189
196
  end
190
-
197
+
191
198
  # Log using the HTML formatter
192
199
  Loggability.formatted_with( :html ) do
193
200
  ...
@@ -210,7 +217,7 @@ You can also make the override only apply to the loggers for a subset of log hos
210
217
  ACME.start_up
211
218
  end
212
219
 
213
- === Configurability
220
+ ### Configurability
214
221
 
215
222
  Loggability has support for the Configurability[https://rubygems.org/gems/configurability]
216
223
  library, which does the same thing for configuration that Loggability does for
@@ -230,39 +237,41 @@ The format of the value of each logger is:
230
237
 
231
238
  where:
232
239
 
233
- [+SEVERITY+]
234
- The log level; one of: +debug+, +info+, +warn+, +error+, or +fatal+
235
- [+TARGET+]
236
- The destination for log messages. This can be the path to a log file, or
237
- one of <tt>'STDOUT'</tt> or <tt>'STDERR'</tt>, which get mapped to the
238
- equivalent filehandle. Optional.
239
- [+FORMAT+]
240
- The name of one of the formatters. Loggability comes with +default+ (plaintext),
241
- +color+ (ANSI colored text), and +html+ formatters. Optional.
240
+ +SEVERITY+
241
+ : The log level; one of: +debug+, +info+, +warn+, +error+, or +fatal+
242
242
 
243
- If the special key <tt>__default__</tt> is included, its config will be used to set
244
- global defaults before the individual configs are applied.
243
+ +TARGET+
244
+ : The destination for log messages. This can be the path to a log file, or
245
+ one of <tt>'STDOUT'</tt> or <tt>'STDERR'</tt>, which get mapped to the
246
+ equivalent filehandle. Optional.
245
247
 
246
- If either of the optional values is unspecified, it is left unchanged from what it
247
- was before configuration.
248
+ +FORMAT+
249
+ : The name of one of the formatters. Loggability comes with +default+
250
+ (plaintext), +color+ (ANSI colored text), and +html+ formatters. Optional.
248
251
 
252
+ If the special key <tt>__default__</tt> is included, its config will be used to
253
+ set global defaults before the individual configs are applied.
249
254
 
250
- === RSpec Helpers
255
+ If either of the optional values is unspecified, it is left unchanged from what
256
+ it was before configuration.
251
257
 
252
- Loggability includes a couple of helper functions for RSpec that allow you to control
253
- log levels for particular specs.
254
258
 
255
- To use it, require <tt>loggability/spechelpers</tt> in your specs (we put it in the
256
- spec helpers file) and then include the helpers from your RSpec config:
259
+ ### RSpec Helpers
257
260
 
258
- require 'loggability/spechelpers'
259
- RSpec.configure do |c|
260
- # ...
261
- c.include( Loggability::SpecHelpers )
262
- end
261
+ Loggability includes a couple of helper functions for RSpec that allow you to
262
+ control log levels for particular specs.
263
+
264
+ To use it, require <tt>loggability/spechelpers</tt> in your specs (we put it in
265
+ the spec helpers file) and then include the helpers from your RSpec config:
263
266
 
264
- This will install a before and after `:all` hook to set the logging levels before each
265
- example group and then reset it before moving on to the next group.
267
+ require 'loggability/spechelpers'
268
+ RSpec.configure do |c|
269
+ # ...
270
+ c.include( Loggability::SpecHelpers )
271
+ end
272
+
273
+ This will install a before and after `:all` hook to set the logging levels
274
+ before each example group and then reset it before moving on to the next group.
266
275
 
267
276
  You can also access the bodies of those hooks manually:
268
277
 
@@ -270,31 +279,31 @@ You can also access the bodies of those hooks manually:
270
279
  reset_logging()
271
280
 
272
281
  The helpers also allow you to set logging levels for a whole example group, for
273
- particular contexts, or even for individual examples using RSpec's metadata hash
274
- syntax:
282
+ particular contexts, or even for individual examples using RSpec's metadata
283
+ hash syntax:
275
284
 
276
285
  # Set logging to 'error' level for each example in this group
277
286
  describe MyClass, logging: :error do
278
-
287
+
279
288
  # ...but for examples in this context, set it to 'fatal'
280
289
  context 'created with a target', log: :fatal do
281
-
290
+
282
291
  # ...except for this one, which logs at 'debug' level
283
292
  it "does something to it", logging: :debug do
284
-
293
+
285
294
  end
286
-
295
+
287
296
  it "does some other stuff, too"
288
-
297
+
289
298
  end
290
-
299
+
291
300
  end
292
301
 
293
- The {setup_logging}[rdoc-ref:Loggability::SpecHelpers.setup_logging] helper
302
+ The [setup_logging](rdoc-ref:Loggability::SpecHelpers.setup_logging) helper
294
303
  also provides support for displaying the logs inline with spec formatters for
295
304
  which outputting the logs to STDERR isn't optimal. The only one that's
296
- currently uses it is the
297
- {'webkit' formatter}[https://rubygems.org/gems/rspec-formatter-webkit], but
305
+ currently uses it is the
306
+ ['webkit' formatter](https://rubygems.org/gems/rspec-formatter-webkit), but
298
307
  it should be easy to adapt to other HTML displays as well.
299
308
 
300
309
  It looks for either an +HTML_LOGGING+ environment variable, or for the
@@ -307,23 +316,21 @@ This can be used to append logs to each example when the formatter
307
316
  builds the output.
308
317
 
309
318
 
310
- == Contributing
319
+ ## Contributing
311
320
 
312
321
  You can check out the current development source with
313
- Mercurial[http://bitbucket.org/ged/loggability], or if you prefer Git, via
314
- {its Github mirror}[https://github.com/ged/loggability].
322
+ Mercurial[http://hg.sr.ht/~ged/Loggability], or if you prefer Git, via
323
+ [its Github mirror](https://github.com/ged/loggability).
315
324
 
316
- After checking out the source, run:
317
325
 
318
- $ rake newb
326
+ ## Author
319
327
 
320
- This task will install any missing dependencies, run the tests/specs,
321
- and generate the API documentation.
328
+ - Michael Granger <ged@faeriemud.org>
322
329
 
323
330
 
324
- == License
331
+ ## License
325
332
 
326
- Copyright (c) 2012-2017, Michael Granger
333
+ Copyright (c) 2012-2020, Michael Granger
327
334
  All rights reserved.
328
335
 
329
336
  Redistribution and use in source and binary forms, with or without
data/Rakefile CHANGED
@@ -1,81 +1,9 @@
1
- #!/usr/bin/env rake
1
+ #!/usr/bin/env ruby -S rake
2
2
 
3
- require 'rake/clean'
3
+ require 'rake/deveiate'
4
4
 
5
- begin
6
- require 'hoe'
7
- rescue LoadError
8
- abort "This Rakefile requires 'hoe' (gem install hoe)"
5
+ Rake::DevEiate.setup( 'loggability' ) do |project|
6
+ project.required_ruby_version = ['~> 2.5', '~> 3.0']
7
+ project.publish_to = 'deveiate:/usr/local/www/public/code'
9
8
  end
10
9
 
11
- GEMSPEC = 'loggability.gemspec'
12
-
13
- Hoe.plugin :mercurial
14
- Hoe.plugin :signing
15
- Hoe.plugin :deveiate
16
-
17
- Hoe.plugins.delete :rubyforge
18
-
19
- hoespec = Hoe.spec 'loggability' do
20
- self.readme_file = 'README.rdoc'
21
- self.history_file = 'History.rdoc'
22
- self.extra_rdoc_files = FileList[ '*.rdoc' ]
23
-
24
- self.developer 'Michael Granger', 'ged@FaerieMUD.org'
25
-
26
- self.dependency 'hoe-deveiate', '~> 0.4', :developer
27
- self.dependency 'hoe-bundler', '~> 1.2', :developer
28
- self.dependency 'simplecov', '~> 0.7', :developer
29
- self.dependency 'configurability', '~> 3.1', :developer
30
-
31
- self.license "Ruby"
32
- self.require_ruby_version( '>=1.9.3' )
33
- self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
34
- self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
35
-
36
- self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
37
- end
38
-
39
- ENV['VERSION'] ||= hoespec.spec.version.to_s
40
-
41
- # Ensure the specs pass before checking in
42
- task 'hg:precheckin' => [ :check_history, :check_manifest, :gemspec, :spec ]
43
-
44
-
45
- desc "Build a coverage report"
46
- task :coverage do
47
- ENV["COVERAGE"] = 'yes'
48
- Rake::Task[:spec].invoke
49
- end
50
- CLOBBER.include( 'coverage' )
51
-
52
-
53
- # Use the fivefish formatter for docs generated from development checkout
54
- if File.directory?( '.hg' )
55
- require 'rdoc/task'
56
-
57
- Rake::Task[ 'docs' ].clear
58
- RDoc::Task.new( 'docs' ) do |rdoc|
59
- rdoc.main = "README.rdoc"
60
- rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
61
- rdoc.generator = :fivefish
62
- rdoc.title = 'Loggability'
63
- rdoc.rdoc_dir = 'doc'
64
- end
65
- end
66
-
67
- task :gemspec => GEMSPEC
68
- file GEMSPEC => [ __FILE__, 'lib/loggability.rb' ]
69
- task GEMSPEC do |task|
70
- hoespec = $hoespec.spec
71
- hoespec.files.delete( '.gemtest' )
72
- hoespec.signing_key = nil
73
- hoespec.version = "#{hoespec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
74
- hoespec.cert_chain = [ 'certs/ged.pem' ]
75
- File.open( task.name, 'w' ) do |fh|
76
- fh.write( hoespec.to_ruby )
77
- end
78
- end
79
-
80
- CLOBBER.include( GEMSPEC.to_s )
81
-