semantic_logger 5.1.0 → 5.3.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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -12
  3. data/Rakefile +15 -4
  4. data/docs/api.md +196 -19
  5. data/docs/appenders.md +579 -68
  6. data/docs/config.md +647 -38
  7. data/docs/index.md +31 -5
  8. data/docs/log.md +56 -17
  9. data/docs/metrics.md +144 -30
  10. data/docs/operations.md +339 -24
  11. data/docs/rails.md +396 -8
  12. data/docs/security.md +222 -27
  13. data/docs/testing.md +28 -3
  14. data/docs/upgrading.md +938 -7
  15. data/lib/semantic_logger/appender/async.rb +42 -11
  16. data/lib/semantic_logger/appender/bugsnag.rb +7 -2
  17. data/lib/semantic_logger/appender/cloudwatch_logs.rb +168 -33
  18. data/lib/semantic_logger/appender/elasticsearch_base.rb +221 -28
  19. data/lib/semantic_logger/appender/elasticsearch_http.rb +23 -6
  20. data/lib/semantic_logger/appender/file.rb +160 -37
  21. data/lib/semantic_logger/appender/graylog.rb +101 -11
  22. data/lib/semantic_logger/appender/honeybadger.rb +7 -1
  23. data/lib/semantic_logger/appender/honeybadger_insights.rb +8 -2
  24. data/lib/semantic_logger/appender/http.rb +308 -46
  25. data/lib/semantic_logger/appender/io.rb +11 -6
  26. data/lib/semantic_logger/appender/kafka.rb +204 -44
  27. data/lib/semantic_logger/appender/loki.rb +55 -9
  28. data/lib/semantic_logger/appender/mongodb.rb +109 -5
  29. data/lib/semantic_logger/appender/new_relic.rb +3 -4
  30. data/lib/semantic_logger/appender/new_relic_logs.rb +35 -15
  31. data/lib/semantic_logger/appender/open_telemetry.rb +37 -35
  32. data/lib/semantic_logger/appender/rabbitmq.rb +246 -17
  33. data/lib/semantic_logger/appender/sentry.rb +3 -4
  34. data/lib/semantic_logger/appender/sentry_ruby.rb +159 -18
  35. data/lib/semantic_logger/appender/splunk.rb +11 -2
  36. data/lib/semantic_logger/appender/splunk_http.rb +92 -1
  37. data/lib/semantic_logger/appender/syslog.rb +149 -32
  38. data/lib/semantic_logger/appender/tcp.rb +73 -98
  39. data/lib/semantic_logger/appender/text_output.rb +65 -0
  40. data/lib/semantic_logger/appender/udp.rb +140 -18
  41. data/lib/semantic_logger/appender/wrapper.rb +10 -7
  42. data/lib/semantic_logger/appender.rb +115 -10
  43. data/lib/semantic_logger/appenders.rb +145 -5
  44. data/lib/semantic_logger/backtrace_cleaning.rb +77 -0
  45. data/lib/semantic_logger/base.rb +115 -81
  46. data/lib/semantic_logger/call_site.rb +235 -0
  47. data/lib/semantic_logger/context.rb +222 -0
  48. data/lib/semantic_logger/core_ext/process.rb +20 -5
  49. data/lib/semantic_logger/core_ext/warning.rb +70 -0
  50. data/lib/semantic_logger/deprecation.rb +139 -0
  51. data/lib/semantic_logger/exception_details.rb +51 -0
  52. data/lib/semantic_logger/formatters/base.rb +186 -20
  53. data/lib/semantic_logger/formatters/color.rb +18 -3
  54. data/lib/semantic_logger/formatters/default.rb +53 -8
  55. data/lib/semantic_logger/formatters/ecs.rb +9 -4
  56. data/lib/semantic_logger/formatters/json.rb +9 -0
  57. data/lib/semantic_logger/formatters/logfmt.rb +155 -21
  58. data/lib/semantic_logger/formatters/loki/labels.rb +282 -0
  59. data/lib/semantic_logger/formatters/loki.rb +430 -38
  60. data/lib/semantic_logger/formatters/new_relic_logs.rb +15 -13
  61. data/lib/semantic_logger/formatters/one_line.rb +101 -3
  62. data/lib/semantic_logger/formatters/open_telemetry.rb +191 -35
  63. data/lib/semantic_logger/formatters/pattern.rb +68 -12
  64. data/lib/semantic_logger/formatters/raw.rb +40 -11
  65. data/lib/semantic_logger/formatters/signalfx.rb +55 -15
  66. data/lib/semantic_logger/formatters/syslog.rb +114 -20
  67. data/lib/semantic_logger/formatters/syslog_cee.rb +38 -19
  68. data/lib/semantic_logger/formatters/syslog_header.rb +49 -0
  69. data/lib/semantic_logger/formatters.rb +1 -0
  70. data/lib/semantic_logger/levels.rb +10 -1
  71. data/lib/semantic_logger/log.rb +384 -82
  72. data/lib/semantic_logger/loggable.rb +56 -73
  73. data/lib/semantic_logger/logger.rb +31 -5
  74. data/lib/semantic_logger/metric/new_relic.rb +33 -18
  75. data/lib/semantic_logger/metric/signalfx.rb +29 -18
  76. data/lib/semantic_logger/metric/statsd.rb +41 -15
  77. data/lib/semantic_logger/processor.rb +194 -5
  78. data/lib/semantic_logger/queue_processor/backoff.rb +140 -0
  79. data/lib/semantic_logger/queue_processor/batch_failure.rb +69 -0
  80. data/lib/semantic_logger/queue_processor/held_write.rb +62 -0
  81. data/lib/semantic_logger/queue_processor/inbox.rb +97 -0
  82. data/lib/semantic_logger/queue_processor/reopener.rb +56 -0
  83. data/lib/semantic_logger/queue_processor/reporter.rb +113 -0
  84. data/lib/semantic_logger/queue_processor/request.rb +93 -0
  85. data/lib/semantic_logger/queue_processor/throttled_counter.rb +89 -0
  86. data/lib/semantic_logger/queue_processor.rb +519 -170
  87. data/lib/semantic_logger/ractor_copy.rb +120 -0
  88. data/lib/semantic_logger/ractor_processor.rb +82 -0
  89. data/lib/semantic_logger/ractor_receiver.rb +282 -0
  90. data/lib/semantic_logger/ractor_support.rb +28 -0
  91. data/lib/semantic_logger/redactor.rb +310 -0
  92. data/lib/semantic_logger/semantic_logger.rb +328 -81
  93. data/lib/semantic_logger/subscriber.rb +250 -10
  94. data/lib/semantic_logger/sync_processor.rb +237 -26
  95. data/lib/semantic_logger/test/capture_log_events.rb +26 -5
  96. data/lib/semantic_logger/test/minitest.rb +2 -1
  97. data/lib/semantic_logger/test/rspec.rb +1 -1
  98. data/lib/semantic_logger/trap_safe.rb +113 -0
  99. data/lib/semantic_logger/utils.rb +482 -67
  100. data/lib/semantic_logger/version.rb +1 -1
  101. data/lib/semantic_logger.rb +36 -3
  102. metadata +41 -5
  103. data/lib/semantic_logger/core_ext/thread.rb +0 -30
@@ -1,11 +1,18 @@
1
1
  require "concurrent"
2
- require "semantic_logger/core_ext/thread"
3
2
  require "semantic_logger/version"
4
3
  require "semantic_logger/utils"
4
+ require "semantic_logger/trap_safe"
5
5
  require "semantic_logger/ansi_colors"
6
6
  require "semantic_logger/levels"
7
+ require "semantic_logger/ractor_support"
8
+ require "semantic_logger/deprecation"
9
+ require "semantic_logger/context"
7
10
  require "semantic_logger/base"
8
11
  require "semantic_logger/formatters"
12
+ require "semantic_logger/exception_details"
13
+ require "semantic_logger/backtrace_cleaning"
14
+ require "semantic_logger/redactor"
15
+ require "semantic_logger/call_site"
9
16
  require "semantic_logger/log"
10
17
  require "semantic_logger/subscriber"
11
18
  require "semantic_logger/loggable"
@@ -19,6 +26,13 @@ require "semantic_logger/logger"
19
26
  require "semantic_logger/debug_as_trace_logger"
20
27
  require "semantic_logger/semantic_logger"
21
28
 
29
+ # Logging from Ractors other than the main one (experimental), on Ruby 4.0 and later.
30
+ if SemanticLogger::RactorSupport.enabled?
31
+ require "semantic_logger/ractor_copy"
32
+ require "semantic_logger/ractor_receiver"
33
+ require "semantic_logger/ractor_processor"
34
+ end
35
+
22
36
  # Automatically reopen appenders in the child process after a fork.
23
37
  # Enabled by default; opt out with `SemanticLogger.reopen_on_fork = false`.
24
38
  # Skipped on platforms without `Process._fork` (e.g. JRuby), which cannot fork.
@@ -27,9 +41,28 @@ if Process.respond_to?(:_fork)
27
41
  Process.singleton_class.prepend(SemanticLogger::CoreExt::Process)
28
42
  end
29
43
 
30
- # Flush all appenders at exit, waiting for outstanding messages on the queue
31
- # to be written first.
44
+ # json 2.8.0 through 3.0.x warn about each binary String they write as UTF-8. Drop that warning
45
+ # when it comes from Semantic Logger serializing log data, which it writes the same way with
46
+ # json 3.1 (see SemanticLogger::CoreExt::Warning).
47
+ Warning.singleton_class.prepend(SemanticLogger::CoreExt::Warning) if SemanticLogger::CoreExt::Warning::NEEDED
48
+
49
+ # Flush all appenders at exit, waiting for outstanding messages on the queue to be written first.
50
+ #
51
+ # During an outage of the destination of an appender added with async: true or in batches, that would
52
+ # wait while each queued message failed in turn, which can take hours against a server that does not
53
+ # answer. So the appenders are first told that the process is exiting, each one directly: the thread
54
+ # that writes to every appender can be held up handing a message to that appender's full queue while
55
+ # it backs off, and so would hand it the flush only once it stopped backing off. Each one then stops
56
+ # backing off and writing again what failed, and once its destination fails a write, discards the
57
+ # rest of its queue. An appender without a queue of its own, such as a plain :http, would make that
58
+ # thread wait while each message failed in turn instead, so once its destination fails a write, it is
59
+ # given no more messages (see SemanticLogger::Appenders#process_exiting=). They are told again once
60
+ # the flush has returned, since a test framework can run its tests in a later at_exit hook.
32
61
  at_exit do
62
+ appenders = SemanticLogger.appenders
63
+ appenders.process_exiting = true
33
64
  # Cannot close since test frameworks only run at exit, at which point the logging would already be closed.
34
65
  SemanticLogger.flush
66
+ ensure
67
+ appenders&.process_exiting = false
35
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '1.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: logger
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.5'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
26
40
  description: Semantic Logger is a high-performance, asynchronous structured logging
27
41
  framework for Ruby & Rails. It logs to multiple destinations via a background thread,
28
42
  preserving structured (semantic) payloads.
@@ -73,14 +87,20 @@ files:
73
87
  - lib/semantic_logger/appender/splunk_http.rb
74
88
  - lib/semantic_logger/appender/syslog.rb
75
89
  - lib/semantic_logger/appender/tcp.rb
90
+ - lib/semantic_logger/appender/text_output.rb
76
91
  - lib/semantic_logger/appender/udp.rb
77
92
  - lib/semantic_logger/appender/wrapper.rb
78
93
  - lib/semantic_logger/appenders.rb
94
+ - lib/semantic_logger/backtrace_cleaning.rb
79
95
  - lib/semantic_logger/base.rb
96
+ - lib/semantic_logger/call_site.rb
80
97
  - lib/semantic_logger/concerns/compatibility.rb
98
+ - lib/semantic_logger/context.rb
81
99
  - lib/semantic_logger/core_ext/process.rb
82
- - lib/semantic_logger/core_ext/thread.rb
100
+ - lib/semantic_logger/core_ext/warning.rb
83
101
  - lib/semantic_logger/debug_as_trace_logger.rb
102
+ - lib/semantic_logger/deprecation.rb
103
+ - lib/semantic_logger/exception_details.rb
84
104
  - lib/semantic_logger/formatters.rb
85
105
  - lib/semantic_logger/formatters/base.rb
86
106
  - lib/semantic_logger/formatters/color.rb
@@ -90,6 +110,7 @@ files:
90
110
  - lib/semantic_logger/formatters/json.rb
91
111
  - lib/semantic_logger/formatters/logfmt.rb
92
112
  - lib/semantic_logger/formatters/loki.rb
113
+ - lib/semantic_logger/formatters/loki/labels.rb
93
114
  - lib/semantic_logger/formatters/new_relic_logs.rb
94
115
  - lib/semantic_logger/formatters/one_line.rb
95
116
  - lib/semantic_logger/formatters/open_telemetry.rb
@@ -98,6 +119,7 @@ files:
98
119
  - lib/semantic_logger/formatters/signalfx.rb
99
120
  - lib/semantic_logger/formatters/syslog.rb
100
121
  - lib/semantic_logger/formatters/syslog_cee.rb
122
+ - lib/semantic_logger/formatters/syslog_header.rb
101
123
  - lib/semantic_logger/jruby/garbage_collection_logger.rb
102
124
  - lib/semantic_logger/levels.rb
103
125
  - lib/semantic_logger/log.rb
@@ -108,6 +130,19 @@ files:
108
130
  - lib/semantic_logger/metric/statsd.rb
109
131
  - lib/semantic_logger/processor.rb
110
132
  - lib/semantic_logger/queue_processor.rb
133
+ - lib/semantic_logger/queue_processor/backoff.rb
134
+ - lib/semantic_logger/queue_processor/batch_failure.rb
135
+ - lib/semantic_logger/queue_processor/held_write.rb
136
+ - lib/semantic_logger/queue_processor/inbox.rb
137
+ - lib/semantic_logger/queue_processor/reopener.rb
138
+ - lib/semantic_logger/queue_processor/reporter.rb
139
+ - lib/semantic_logger/queue_processor/request.rb
140
+ - lib/semantic_logger/queue_processor/throttled_counter.rb
141
+ - lib/semantic_logger/ractor_copy.rb
142
+ - lib/semantic_logger/ractor_processor.rb
143
+ - lib/semantic_logger/ractor_receiver.rb
144
+ - lib/semantic_logger/ractor_support.rb
145
+ - lib/semantic_logger/redactor.rb
111
146
  - lib/semantic_logger/reporters/minitest.rb
112
147
  - lib/semantic_logger/semantic_logger.rb
113
148
  - lib/semantic_logger/subscriber.rb
@@ -116,16 +151,17 @@ files:
116
151
  - lib/semantic_logger/test/capture_log_events.rb
117
152
  - lib/semantic_logger/test/minitest.rb
118
153
  - lib/semantic_logger/test/rspec.rb
154
+ - lib/semantic_logger/trap_safe.rb
119
155
  - lib/semantic_logger/utils.rb
120
156
  - lib/semantic_logger/version.rb
121
- homepage: https://logger.rocketjob.io
157
+ homepage: https://logger.reidmorrison.com
122
158
  licenses:
123
159
  - Apache-2.0
124
160
  metadata:
125
161
  bug_tracker_uri: https://github.com/reidmorrison/semantic_logger/issues
126
162
  changelog_uri: https://github.com/reidmorrison/semantic_logger/blob/main/CHANGELOG.md
127
- documentation_uri: https://logger.rocketjob.io
128
- source_code_uri: https://github.com/reidmorrison/semantic_logger/tree/v5.1.0
163
+ documentation_uri: https://logger.reidmorrison.com
164
+ source_code_uri: https://github.com/reidmorrison/semantic_logger/tree/v5.3.0
129
165
  rubygems_mfa_required: 'true'
130
166
  rdoc_options: []
131
167
  require_paths:
@@ -1,30 +0,0 @@
1
- class Thread
2
- undef :name if method_defined? :name
3
- undef :name= if method_defined? :name=
4
-
5
- # Returns the name of the current thread
6
- # Default:
7
- # JRuby: The underlying Java thread name
8
- # Other: String representation of this thread's object_id
9
- if defined? JRuby
10
- def name
11
- @name ||= JRuby.reference(self).native_thread.name
12
- end
13
- else
14
- def name
15
- @name ||= object_id.to_s
16
- end
17
- end
18
-
19
- # Set the name of this thread
20
- # On JRuby it also sets the underlying Java Thread name
21
- if defined? JRuby
22
- def name=(name)
23
- JRuby.reference(self).native_thread.name = @name = name.to_s
24
- end
25
- else
26
- def name=(name)
27
- @name = name.to_s
28
- end
29
- end
30
- end