dry-logger 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db1b993bbb542d2c6ea65c7b3f434e93e57b383786ad6a768742f1c1743fc099
4
- data.tar.gz: c9768e9a036e76d5625834951ac5d973e247dbb6dbb53f7d2ab96e40c1138941
3
+ metadata.gz: 04cd0f59a52a7ad5d6aead697ec9110a8e8f53dff1c6a4f38d382643dc7262fc
4
+ data.tar.gz: 811b9b8d248e1b6785492c1ce2aa6269620b913749c9c685e0bcda61a0c7cc22
5
5
  SHA512:
6
- metadata.gz: 2599bc67c68ce63e96e698c9e4602c292ff43efcd531b6f63d053a61e7eebd171b1815613d3c3d80af7e2f816d0802c5015cef62a8d010db308db588e023f19d
7
- data.tar.gz: bcea5f71bc21cabf925a4509682873b0f5c943d396f96c7f8e4e460d589a4ef6dd585f56ace3cc59398380c7c93099953c2275ecfb92cd0193251450439dcdee
6
+ metadata.gz: 9990fbd5d1a787288bdc8a7ba2457a53ee5a459196c7b6e585c40beab18ca5bdffc8b4adf85d5f49055f2bffa8f60dc85136c384e9ae7a78860872f914a6fc85
7
+ data.tar.gz: 2bfd9b32587436d6760e157a87a1e3b2043fa6d807d158663c5642eae2fe9cb541f50852fbd411588c4fd0c7eabbeb1e0bb981721382d928cb742ca059c74f2f
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
- ## unreleased
3
+ ## 1.0.4 2024-05-10
4
+
5
+
6
+ ### Fixed
7
+
8
+ - Accept log messages via given block, ensuring compatibility with standard Ruby logger (via #28) (@komidore64)
9
+
10
+ ### Changed
11
+
12
+ - Drop support for Ruby 2.7 (via #29) (@timriley)
13
+
14
+ [Compare v1.0.3...v1.0.4](https://github.com/dry-rb/dry-logger/compare/v1.0.3...v1.0.4)
15
+
16
+ ## 1.0.3 2022-12-09
4
17
 
5
18
 
6
19
  ### Added
@@ -8,7 +21,7 @@
8
21
  - Support for ruby 2.7 (needs backports gem that *you* need to add to your Gemfile) (via #24) (@solnic)
9
22
 
10
23
 
11
- [Compare v1.0.2...master](https://github.com/dry-rb/dry-logger/compare/v1.0.2...master)
24
+ [Compare v1.0.2...v1.0.3](https://github.com/dry-rb/dry-logger/compare/v1.0.2...v1.0.3)
12
25
 
13
26
  ## 1.0.2 2022-11-24
14
27
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2022 dry-rb team
3
+ Copyright (c) 2015-2023 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  <!--- this file is synced from dry-rb/template-gem project -->
2
+
2
3
  [gem]: https://rubygems.org/gems/dry-logger
3
4
  [actions]: https://github.com/dry-rb/dry-logger/actions
4
5
 
5
- # dry-logger [![Gem Version](https://badge.fury.io/rb/dry-logger.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-logger/workflows/ci/badge.svg)][actions]
6
+ # dry-logger [![Gem Version](https://badge.fury.io/rb/dry-logger.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-logger/workflows/CI/badge.svg)][actions]
6
7
 
7
8
  ## Links
8
9
 
@@ -14,8 +15,8 @@
14
15
 
15
16
  This library officially supports the following Ruby versions:
16
17
 
17
- * MRI `>= 2.7.0`
18
- * jruby `>= 9.3` (postponed until 2.7 is supported)
18
+ * MRI `>= 3.0`
19
+ * jruby `>= 9.4` (not tested on CI)
19
20
 
20
21
  ## License
21
22
 
data/dry-logger.gemspec CHANGED
@@ -8,8 +8,8 @@ require "dry/logger/version"
8
8
 
9
9
  Gem::Specification.new do |spec|
10
10
  spec.name = "dry-logger"
11
- spec.authors = ["Luca Guidi"]
12
- spec.email = ["me@lucaguidi.com"]
11
+ spec.authors = ["Luca Guidi", "Peter Solnica"]
12
+ spec.email = ["me@lucaguidi.com", "peter@solnica.online"]
13
13
  spec.license = "MIT"
14
14
  spec.version = Dry::Logger::VERSION.dup
15
15
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-logger"
27
27
  spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-logger/issues"
28
28
 
29
- spec.required_ruby_version = ">= 2.7"
29
+ spec.required_ruby_version = ">= 3.0"
30
30
 
31
31
  # to update dependencies edit project.yml
32
32
 
@@ -58,7 +58,7 @@ module Dry
58
58
 
59
59
  # @since 1.0.0
60
60
  # @api private
61
- LEVEL_RANGE = (DEBUG..UNKNOWN).freeze
61
+ LEVEL_RANGE = (DEBUG..UNKNOWN)
62
62
 
63
63
  # @since 1.0.0
64
64
  # @api private
@@ -110,8 +110,8 @@ module Dry
110
110
  # @see Dispatcher#log
111
111
  # @api public
112
112
  # @return [true]
113
- def unknown(message = nil, **payload)
114
- log(:unknown, message, **payload)
113
+ def unknown(message = nil, **payload, &block)
114
+ log(:unknown, message, **payload, &block)
115
115
  end
116
116
 
117
117
  # Log an entry with DEBUG severity
@@ -119,8 +119,8 @@ module Dry
119
119
  # @see Dispatcher#log
120
120
  # @api public
121
121
  # @return [true]
122
- def debug(message = nil, **payload)
123
- log(:debug, message, **payload)
122
+ def debug(message = nil, **payload, &block)
123
+ log(:debug, message, **payload, &block)
124
124
  end
125
125
 
126
126
  # Log an entry with INFO severity
@@ -128,8 +128,8 @@ module Dry
128
128
  # @see Dispatcher#log
129
129
  # @api public
130
130
  # @return [true]
131
- def info(message = nil, **payload)
132
- log(:info, message, **payload)
131
+ def info(message = nil, **payload, &block)
132
+ log(:info, message, **payload, &block)
133
133
  end
134
134
 
135
135
  # Log an entry with WARN severity
@@ -137,8 +137,8 @@ module Dry
137
137
  # @see Dispatcher#log
138
138
  # @api public
139
139
  # @return [true]
140
- def warn(message = nil, **payload)
141
- log(:warn, message, **payload)
140
+ def warn(message = nil, **payload, &block)
141
+ log(:warn, message, **payload, &block)
142
142
  end
143
143
 
144
144
  # Log an entry with ERROR severity
@@ -146,8 +146,8 @@ module Dry
146
146
  # @see Dispatcher#log
147
147
  # @api public
148
148
  # @return [true]
149
- def error(message = nil, **payload)
150
- log(:error, message, **payload)
149
+ def error(message = nil, **payload, &block)
150
+ log(:error, message, **payload, &block)
151
151
  end
152
152
 
153
153
  # Log an entry with FATAL severity
@@ -155,8 +155,8 @@ module Dry
155
155
  # @see Dispatcher#log
156
156
  # @api public
157
157
  # @return [true]
158
- def fatal(message = nil, **payload)
159
- log(:fatal, message, **payload)
158
+ def fatal(message = nil, **payload, &block)
159
+ log(:fatal, message, **payload, &block)
160
160
  end
161
161
 
162
162
  BACKEND_METHODS.each do |name|
@@ -179,6 +179,9 @@ module Dry
179
179
  # @example logging a message
180
180
  # logger.log(:info, "Hello World")
181
181
  #
182
+ # @example logging a message by passing a block
183
+ # logger.log(:debug, "Sidecar") { "Hello World" }
184
+ #
182
185
  # @example logging payload
183
186
  # logger.log(:info, verb: "GET", path: "/users")
184
187
  #
@@ -196,17 +199,25 @@ module Dry
196
199
  # @param [Symbol] severity The log severity name
197
200
  # @param [String] message Optional message
198
201
  # @param [Hash] payload Optional log entry payload
202
+ # @yield
203
+ # @yieldreturn [String] Message to be logged
199
204
  #
200
205
  # @since 1.0.0
201
206
  # @return [true]
202
207
  # @api public
203
- def log(severity, message = nil, **payload)
208
+ def log(severity, message = nil, **payload, &block)
204
209
  case message
205
- when Hash then log(severity, nil, **message)
210
+ when Hash then log(severity, **message, &block)
206
211
  else
212
+ if block
213
+ progname = message
214
+ message = block.call
215
+ end
216
+ progname ||= id
217
+
207
218
  entry = Entry.new(
208
219
  clock: clock,
209
- progname: id,
220
+ progname: progname,
210
221
  severity: severity,
211
222
  tags: @tags,
212
223
  message: message,
@@ -16,7 +16,7 @@ module Dry
16
16
  class Template
17
17
  # @since 1.0.0
18
18
  # @api private
19
- TOKEN_REGEXP = /%<(\w*)>s/.freeze
19
+ TOKEN_REGEXP = /%<(\w*)>s/
20
20
 
21
21
  # @since 1.0.0
22
22
  # @api private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Logger
5
- VERSION = "1.0.3"
5
+ VERSION = "1.0.4"
6
6
  end
7
7
  end
data/lib/dry/logger.rb CHANGED
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- if RUBY_VERSION < "3"
4
- require "backports/3.0.0/hash/except"
5
- end
6
-
7
3
  require "dry/logger/global"
8
4
  require "dry/logger/constants"
9
5
  require "dry/logger/clock"
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
+ - Peter Solnica
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2022-12-09 00:00:00.000000000 Z
12
+ date: 2024-05-10 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
@@ -27,6 +28,7 @@ dependencies:
27
28
  description: Logging for Ruby
28
29
  email:
29
30
  - me@lucaguidi.com
31
+ - peter@solnica.online
30
32
  executables: []
31
33
  extensions: []
32
34
  extra_rdoc_files: []
@@ -70,14 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
72
  requirements:
71
73
  - - ">="
72
74
  - !ruby/object:Gem::Version
73
- version: '2.7'
75
+ version: '3.0'
74
76
  required_rubygems_version: !ruby/object:Gem::Requirement
75
77
  requirements:
76
78
  - - ">="
77
79
  - !ruby/object:Gem::Version
78
80
  version: '0'
79
81
  requirements: []
80
- rubygems_version: 3.1.6
82
+ rubygems_version: 3.3.27
81
83
  signing_key:
82
84
  specification_version: 4
83
85
  summary: Logging for Ruby