lumberjack 1.2.8 → 1.2.10

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +152 -58
  3. data/README.md +35 -6
  4. data/VERSION +1 -1
  5. data/lib/lumberjack/context.rb +13 -0
  6. data/lib/lumberjack/device/date_rolling_log_file.rb +10 -1
  7. data/lib/lumberjack/device/log_file.rb +8 -1
  8. data/lib/lumberjack/device/multi.rb +2 -1
  9. data/lib/lumberjack/device/null.rb +1 -1
  10. data/lib/lumberjack/device/rolling_log_file.rb +22 -22
  11. data/lib/lumberjack/device/size_rolling_log_file.rb +1 -1
  12. data/lib/lumberjack/device/writer.rb +21 -1
  13. data/lib/lumberjack/device.rb +16 -1
  14. data/lib/lumberjack/formatter/date_time_formatter.rb +2 -1
  15. data/lib/lumberjack/formatter/exception_formatter.rb +4 -2
  16. data/lib/lumberjack/formatter/id_formatter.rb +2 -1
  17. data/lib/lumberjack/formatter/inspect_formatter.rb +1 -1
  18. data/lib/lumberjack/formatter/object_formatter.rb +1 -1
  19. data/lib/lumberjack/formatter/pretty_print_formatter.rb +3 -1
  20. data/lib/lumberjack/formatter/string_formatter.rb +1 -1
  21. data/lib/lumberjack/formatter/strip_formatter.rb +1 -1
  22. data/lib/lumberjack/formatter/structured_formatter.rb +3 -1
  23. data/lib/lumberjack/formatter/truncate_formatter.rb +27 -0
  24. data/lib/lumberjack/formatter.rb +55 -9
  25. data/lib/lumberjack/log_entry.rb +10 -2
  26. data/lib/lumberjack/logger.rb +141 -18
  27. data/lib/lumberjack/rack/context.rb +1 -1
  28. data/lib/lumberjack/rack/request_id.rb +1 -1
  29. data/lib/lumberjack/rack/unit_of_work.rb +1 -1
  30. data/lib/lumberjack/rack.rb +1 -1
  31. data/lib/lumberjack/severity.rb +21 -1
  32. data/lib/lumberjack/tag_formatter.rb +19 -0
  33. data/lib/lumberjack/tagged_logger_support.rb +1 -1
  34. data/lib/lumberjack/tags.rb +6 -0
  35. data/lib/lumberjack/template.rb +15 -3
  36. data/lib/lumberjack.rb +20 -2
  37. metadata +8 -7
data/lib/lumberjack.rb CHANGED
@@ -1,12 +1,13 @@
1
- # frozen_string_literals: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  require "rbconfig"
4
4
  require "time"
5
5
  require "securerandom"
6
6
  require "logger"
7
+ require "fiber"
7
8
 
8
9
  module Lumberjack
9
- LINE_SEPARATOR = (RbConfig::CONFIG["host_os"] =~ /mswin/i ? "\r\n" : "\n")
10
+ LINE_SEPARATOR = ((RbConfig::CONFIG["host_os"] =~ /mswin/i) ? "\r\n" : "\n")
10
11
 
11
12
  require_relative "lumberjack/severity"
12
13
  require_relative "lumberjack/formatter"
@@ -32,6 +33,9 @@ module Lumberjack
32
33
  #
33
34
  # For the common use case of treating a single web request as a unit of work, see the
34
35
  # Lumberjack::Rack::UnitOfWork class.
36
+ #
37
+ # @param [String] id The id for the unit of work.
38
+ # @return [void]
35
39
  def unit_of_work(id = nil)
36
40
  id ||= SecureRandom.hex(6)
37
41
  context do
@@ -41,6 +45,8 @@ module Lumberjack
41
45
  end
42
46
 
43
47
  # Get the UniqueIdentifier for the current unit of work.
48
+ #
49
+ # @return [String, nil] The id for the current unit of work.
44
50
  def unit_of_work_id
45
51
  context[:unit_of_work_id]
46
52
  end
@@ -53,6 +59,8 @@ module Lumberjack
53
59
  #
54
60
  # Otherwise, it will return the current context. If one doesn't exist, it will return a new one
55
61
  # but that context will not be in any scope.
62
+ #
63
+ # @return [Lumberjack::Context] The current context if called without a block.
56
64
  def context(&block)
57
65
  current_context = Thread.current[:lumberjack_context]
58
66
  if block
@@ -63,6 +71,9 @@ module Lumberjack
63
71
  end
64
72
 
65
73
  # Set the context to use within a block.
74
+ #
75
+ # @param [Lumberjack::Context] context The context to use within the block.
76
+ # @return [Object] The result of the block.
66
77
  def use_context(context, &block)
67
78
  current_context = Thread.current[:lumberjack_context]
68
79
  begin
@@ -74,17 +85,24 @@ module Lumberjack
74
85
  end
75
86
 
76
87
  # Return true if inside a context block.
88
+ #
89
+ # @return [Boolean]
77
90
  def context?
78
91
  !!Thread.current[:lumberjack_context]
79
92
  end
80
93
 
81
94
  # Return the tags from the current context or nil if there are no tags.
95
+ #
96
+ # @return [Hash, nil]
82
97
  def context_tags
83
98
  context = Thread.current[:lumberjack_context]
84
99
  context&.tags
85
100
  end
86
101
 
87
102
  # Set tags on the current context
103
+ #
104
+ # @param [Hash] tags The tags to set.
105
+ # @return [void]
88
106
  def tag(tags)
89
107
  context = Thread.current[:lumberjack_context]
90
108
  context&.tag(tags)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lumberjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-31 00:00:00.000000000 Z
11
+ date: 2023-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description:
27
+ description:
28
28
  email:
29
29
  - bbdurand@gmail.com
30
30
  executables: []
@@ -55,6 +55,7 @@ files:
55
55
  - lib/lumberjack/formatter/string_formatter.rb
56
56
  - lib/lumberjack/formatter/strip_formatter.rb
57
57
  - lib/lumberjack/formatter/structured_formatter.rb
58
+ - lib/lumberjack/formatter/truncate_formatter.rb
58
59
  - lib/lumberjack/log_entry.rb
59
60
  - lib/lumberjack/logger.rb
60
61
  - lib/lumberjack/rack.rb
@@ -72,7 +73,7 @@ homepage: https://github.com/bdurand/lumberjack
72
73
  licenses:
73
74
  - MIT
74
75
  metadata: {}
75
- post_install_message:
76
+ post_install_message:
76
77
  rdoc_options: []
77
78
  require_paths:
78
79
  - lib
@@ -87,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  - !ruby/object:Gem::Version
88
89
  version: '0'
89
90
  requirements: []
90
- rubygems_version: 3.0.3
91
- signing_key:
91
+ rubygems_version: 3.4.20
92
+ signing_key:
92
93
  specification_version: 4
93
94
  summary: A simple, powerful, and very fast logging utility that can be a drop in replacement
94
95
  for Logger or ActiveSupport::BufferedLogger.