ruby_smart-simple_logger 1.6.0 → 1.6.1

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: 5f377784d8f7f47e7e2e6e8db6af4a59f18141a46dc4a02c6a1e7d065b40d660
4
- data.tar.gz: 23bceaf895ef087fb54620a3b8b09c8c1952da685ce862c8eaafff52bf7756fa
3
+ metadata.gz: 4600b91c524058555c2e5cf031f0b1496816b46427b9e9e3d0db67e501c2394d
4
+ data.tar.gz: 6e837fc7b6d9a594c36036165cb5e5e96384cdef0c887aa6c552d91eb45baa3a
5
5
  SHA512:
6
- metadata.gz: 2c1de42c4b096d61f6c9e085c613cb3d70f82c6aae3abdb4d2f4e488d4eb665576a37d68b22d23fb57d15d6bebbe4231f533c34b12e1e3a079ccb4d6f540acb2
7
- data.tar.gz: e6eef91be3f2e57d15401b9ae6d4768265376957009b3934122d21456b7ad16c1c2322b35aa12b658af027e6407c252a5e5d49cf745ed32a995e28ab78b97b76
6
+ metadata.gz: 7974dd43f3471c4973da06e442db5b8685efa1a561a11437c55f361d270af17609ea679ab1819e41025a6d15fdb6c62d097d8c1296a9671c96710f3bbcd55ae8
7
+ data.tar.gz: dc344203c08448d5008d804cfd65e7b9292e6c625c1462c122564ba5978f0f022e893405e10447a2dc81508a0f2770134dafdd3fe2ca8d974d62869dc6d50da1
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # RubySmart::SimpleLogger - CHANGELOG
2
2
 
3
+ ## [1.6.1] - 2025-10-22
4
+ * **[fix]** Newline _(`nl`)_ related issues on several devices _(i.e. `Debase.logger` / `Rails.logger`)_
5
+
3
6
  ## [1.6.0] - 2025-06-13
4
7
  * **[add]** `Proc` to builtins
5
8
  * **[add]** better specs
@@ -103,8 +103,8 @@ module RubySmart
103
103
  # set default format
104
104
  opts[:format] ||= :plain
105
105
 
106
- # fix nl - which depends on other opts
107
- opts[:nl] = _nl(opts)
106
+ # fix nl
107
+ opts[:nl] = true if opts[:nl].nil?
108
108
 
109
109
  # fix clr
110
110
  opts[:clr] = true if opts[:clr].nil?
@@ -139,7 +139,10 @@ module RubySmart
139
139
 
140
140
  # since some IDEs did a Debase rewriting for Ruby 3.x, the logger is a Proc instead of a Logger instance
141
141
  if ::Debugger.logger.is_a?(Proc)
142
- opts[:format] = :plain # only the data string is forwarded to the proc
142
+ # only the data string is forwarded to the proc
143
+ opts[:format] = :plain
144
+ # the newline is handled by the logger itself
145
+ opts[:nl] = false
143
146
  ::RubySmart::SimpleLogger::Devices::ProcDevice.new(::Debugger.logger)
144
147
  else
145
148
  _resolve_device(::Debugger.logger, opts)
@@ -168,6 +171,8 @@ module RubySmart
168
171
  opts[:format] = :memory
169
172
  # no color logging for memory devices
170
173
  opts[:clr] = false
174
+ # no newline (just for completeness - however the "memory" formatter does NEVER include *nl*)
175
+ opts[:nl] = false
171
176
 
172
177
  ::RubySmart::SimpleLogger::Devices::MemoryDevice.new
173
178
  when Proc
@@ -273,16 +278,6 @@ module RubySmart
273
278
  word
274
279
  end
275
280
 
276
- # returns the +nl+ (new line) flag, depending on the provided options.
277
- # recognizes +:nl+ and +:payload+ options.
278
- # @param [Hash] opts
279
- # @return [Boolean]
280
- def _nl(opts)
281
- return opts[:nl] unless opts[:nl].nil?
282
-
283
- opts[:payload].is_a?(FalseClass)
284
- end
285
-
286
281
  # merge all provided hashes into one single hash
287
282
  #
288
283
  # @example
@@ -171,18 +171,23 @@ module RubySmart
171
171
  end
172
172
  end
173
173
 
174
- # returns the formatted string with a new-line.
174
+ # returns the formatted string with or without a new-line.
175
+ # Also drops a trailing new-line, if it exists.
175
176
  # depends, on the +:nl+ option.
176
177
  # @param [String, Array] data
177
178
  # @return [String]
178
179
  def _nl(data)
179
- # convert to string
180
+ # convert possible array to string
180
181
  data = data.join("\n") if data.is_a?(Array)
181
182
 
182
- # check for +nl+ flag
183
- return data unless opts[:nl]
184
-
185
- data + "\n"
183
+ # check, if a nl-flag should be added or dropped
184
+ if opts[:nl] && data[-1] != "\n"
185
+ data + "\n"
186
+ elsif !opts[:nl] && data[-1] == "\n"
187
+ data[0..-2]
188
+ else
189
+ data
190
+ end
186
191
  end
187
192
 
188
193
  # returns the formatted string with a color-code
@@ -10,7 +10,7 @@ module RubySmart
10
10
  module VERSION
11
11
  MAJOR = 1
12
12
  MINOR = 6
13
- TINY = 0
13
+ TINY = 1
14
14
  PRE = nil
15
15
 
16
16
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -13,11 +13,11 @@ module Debugger
13
13
  extend ::RubySmart::SimpleLogger::KlassLogger
14
14
 
15
15
  # force debugger to 'DEBUG' severity
16
- self.klass_logger_opts = {level: ::RubySmart::SimpleLogger::Logger::DEBUG}
16
+ self.klass_logger_opts = { level: ::RubySmart::SimpleLogger::Logger::DEBUG }
17
17
 
18
- # overwrite existing "debug" method (if Debase was loaded)
19
- def self.debug(*args)
18
+ # overwrite existing "debug" method (if Debase was loaded, this needs to be rewritten)
19
+ def self.debug(*args, **kwargs)
20
20
  return false if args.none?
21
- klass_logger.debug(*args)
21
+ klass_logger.debug(*args, **kwargs)
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_smart-simple_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Gonsior