quonfig 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb6a88a2132fd0fe54fc656ffe1b81916e4487258c2a54dd5589d0bb56b1e300
4
- data.tar.gz: e91e3cce0cc73793e2c0c1fb407192cbd5a8caad9c96bfbfae6d6bf2fa69ea78
3
+ metadata.gz: 875b035905394220e72fec4fc1afc3bc62ad6e2975b745098fa4482e1dc348d0
4
+ data.tar.gz: bd957d0ec077f3a49daf719deb3ea4db64d1b23a69f6264c91385ad21ff06720
5
5
  SHA512:
6
- metadata.gz: d33195dcf4fd9b52f8e245e102fbf21a405626aaa8e1157294a79c83cb8a1f91b78249782a9b7318728f31d342adc9f4565d082886d041d53a44995f8adfcb45
7
- data.tar.gz: fa6b7dd2497f9d202e985619ccccf754162b538c1cd7ffc41d0c7f6679e83d55ac1739d3ed1dc76931b7a9a14be1db9e5f35514a9ff86c9997feecda9342159d
6
+ metadata.gz: 9a592d367c361e42e57c42b0ca0929927808e834b5f876545e17436403b11eb5abe08d2996317e5ec5360a1df2228b48a247e22304d6fcda809c3ffee0e3f772
7
+ data.tar.gz: f3f9b9b1135ab775861164fb89701e6a3cf6b5cb23078d55de89604b13081ce71b7fe00bed192cd9d9134d64fd406fec954efa793e62a2fb558a8ca3cddbec4f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.6 - 2026-04-22
4
+
5
+ - **New: `Quonfig::StdlibFormatter` + `client.stdlib_formatter(logger_name:)`** —
6
+ Ruby's built-in `::Logger` now gets drop-in dynamic log-level gating,
7
+ on par with the existing SemanticLogger integration. The client helper
8
+ returns a Proc matching the stdlib `logger.formatter =` contract
9
+ (`(severity, datetime, progname, msg) -> String`). For each log call
10
+ the proc evaluates `should_log?(logger_path: logger_name || progname,
11
+ desired_level: severity)` and either formats the record or returns an
12
+ empty string (which `::Logger` writes as zero bytes, suppressing the
13
+ line). `logger_name` flows into `quonfig-sdk-logging.key` verbatim —
14
+ no normalization — so customer rules target exact class names.
15
+ Raises `Quonfig::Error` if `logger_key` was not set at init. Parallels
16
+ sdk-node's Winston formatter, sdk-python's `logging.Filter`, and
17
+ sdk-go's `slog.Handler`. Closes Stage 2 of the per-SDK logger-path
18
+ rollout.
19
+
3
20
  ## 0.0.5 - 2026-04-22
4
21
 
5
22
  - **BREAKING — SemanticLoggerFilter context key renamed.** The filter
data/README.md CHANGED
@@ -203,6 +203,42 @@ Pass `key_prefix:` to use a prefix other than `log-levels.`:
203
203
  client.semantic_logger_filter(key_prefix: 'debug.')
204
204
  ```
205
205
 
206
+ ## Dynamic log levels with stdlib Logger
207
+
208
+ If you use Ruby's built-in `::Logger` instead of SemanticLogger, wire the
209
+ formatter returned by `client.stdlib_formatter` into your logger:
210
+
211
+ ```ruby
212
+ require 'quonfig'
213
+ require 'logger'
214
+
215
+ client = Quonfig::Client.new(
216
+ sdk_key: ENV['QUONFIG_BACKEND_SDK_KEY'],
217
+ logger_key: 'log-level.my-app'
218
+ )
219
+
220
+ logger = ::Logger.new($stdout)
221
+ logger.level = ::Logger::DEBUG
222
+ logger.formatter = client.stdlib_formatter(logger_name: 'MyApp::Services::Auth')
223
+ ```
224
+
225
+ The formatter asks the client `should_log?(logger_path:, desired_level:)`
226
+ for every call; lines below the configured level return an empty string
227
+ (which `::Logger` writes as zero bytes, suppressing the line). `logger_name`
228
+ is passed to Quonfig verbatim under `quonfig-sdk-logging.key` so a single
229
+ `log-level.my-app` config can drive per-class overrides via rules like
230
+ `PROP_STARTS_WITH_ONE_OF "MyApp::Services::"`.
231
+
232
+ Omit `logger_name:` to have the formatter fall through to the Logger's
233
+ `progname` at call time:
234
+
235
+ ```ruby
236
+ logger.formatter = client.stdlib_formatter
237
+ logger.progname = 'MyApp::Services::Auth'
238
+ ```
239
+
240
+ If both are supplied, the explicit `logger_name:` wins.
241
+
206
242
  ## Documentation
207
243
 
208
244
  Full documentation, including SPEC, SDK reference, and operational guides, is
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -125,6 +125,29 @@ module Quonfig
125
125
  Quonfig::SemanticLoggerFilter.new(self, config_key: config_key)
126
126
  end
127
127
 
128
+ # Build a formatter Proc for Ruby's built-in +::Logger+. The returned
129
+ # proc honors dynamic log levels from the client's +logger_key+ config:
130
+ # for each log call, it evaluates +should_log?+ and either formats the
131
+ # record or returns an empty string (suppressing output).
132
+ #
133
+ # Matches ReforgeHQ's +stdlib_formatter+ API name (snake_case).
134
+ #
135
+ # Usage:
136
+ # logger = ::Logger.new($stdout)
137
+ # logger.formatter = client.stdlib_formatter # uses progname
138
+ # logger.formatter = client.stdlib_formatter(logger_name: 'MyApp') # fixed name
139
+ #
140
+ # Raises +Quonfig::Error+ if +logger_key+ was not set at init — parallels
141
+ # +should_log?+'s behavior.
142
+ #
143
+ # @param logger_name [String, nil] fallback logger identifier used when
144
+ # +progname+ isn't supplied by the Logger call site. If both are
145
+ # present, +logger_name+ wins.
146
+ # @return [Proc] a +(severity, datetime, progname, msg) -> String+ proc.
147
+ def stdlib_formatter(logger_name: nil)
148
+ Quonfig::StdlibFormatter.build(self, logger_name: logger_name)
149
+ end
150
+
128
151
  # The configured +logger_key+ from Options — the Quonfig config key the
129
152
  # higher-level +should_log?+ helper evaluates per-logger. +nil+ if the
130
153
  # client was not configured for dynamic log levels.
data/lib/quonfig.rb CHANGED
@@ -51,6 +51,7 @@ require 'quonfig/context'
51
51
  require 'quonfig/client'
52
52
  require 'quonfig/bound_client'
53
53
  require 'quonfig/semantic_logger_filter'
54
+ require 'quonfig/stdlib_formatter'
54
55
  require 'quonfig/quonfig'
55
56
  require 'quonfig/murmer3'
56
57
  require 'quonfig/semver'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quonfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer