ruby_smart-simple_logger 1.5.3 → 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: cc624589a3aa7114bbec118563f3f802b046032abe1df2fbddf762971b99bf12
4
- data.tar.gz: 94a9de8091320a9d5395878e1a22362e2ae15d0be0e497f2a6ff3d9f22eeddd4
3
+ metadata.gz: 4600b91c524058555c2e5cf031f0b1496816b46427b9e9e3d0db67e501c2394d
4
+ data.tar.gz: 6e837fc7b6d9a594c36036165cb5e5e96384cdef0c887aa6c552d91eb45baa3a
5
5
  SHA512:
6
- metadata.gz: 7a80eff8cd646906a76abab041aa884fe769a4707e8b9ba7d819707664b71352108f1116eb5530711925bf6d1bc7eac104f5a2086bd050db41177e56d32f0874
7
- data.tar.gz: 92c98897175040fc149e8825db0d1f941197b0aa301ea025731f38fb79a70ac09eff6833ebd622030167c2d530cf9db2dd7b5a9feaaf2ee5838561a9297ff991
6
+ metadata.gz: 7974dd43f3471c4973da06e442db5b8685efa1a561a11437c55f361d270af17609ea679ab1819e41025a6d15fdb6c62d097d8c1296a9671c96710f3bbcd55ae8
7
+ data.tar.gz: dc344203c08448d5008d804cfd65e7b9292e6c625c1462c122564ba5978f0f022e893405e10447a2dc81508a0f2770134dafdd3fe2ca8d974d62869dc6d50da1
data/README.md CHANGED
@@ -39,6 +39,7 @@ Or install it yourself as:
39
39
  * `awesome_print` gem compatibility for a prettified object debug
40
40
  * Multi-device support (write to logfile & to STDOUT & to ... & to ...)
41
41
  * 'klass_logger' instances for easier access _(see [klass_logger](#klass_logger_Usage))_
42
+ * Debug / Debase compatibility
42
43
 
43
44
  -----
44
45
 
@@ -789,12 +790,89 @@ end
789
790
  # ╚ END ❯ Process Alpha (0.001036969)
790
791
  ```
791
792
 
792
- ### _other useful methods_
793
+ ### model(mdl, opts)
794
+ Useful for rails applications to debug or log a save _(create/update)_ result of a model.
795
+ The `model` method logs in three different scenes `SUCCESS ERROR INFO`, depending on the models state: created, updated, error, skipped
793
796
 
794
- - line
795
- - print
796
- - nl
797
- - model _(rails only)_
797
+ ```ruby
798
+ require 'simple_logger'
799
+ l = SimpleLogger.new(:stdout, payload: false)
800
+
801
+ # create a model and save it (with validation errors)
802
+ mdl = User.new first_name: 'Max'
803
+ mdl.save
804
+
805
+ # log the result
806
+ l.model(mdl)
807
+
808
+ # creates an ERROR of:
809
+ # [USER|ERROR] Max (E-Mail is invalid, Username is invalid)
810
+
811
+ # ------------------------------------------------------------------------------------------
812
+
813
+ # update the model to prevent validation errors
814
+ mdl.username = 'test'
815
+ mdl.email = 'max@test.x'
816
+ mdl.save
817
+
818
+ # creates an SUCCESS of:
819
+ # [USER|CREATED] #1 - Max
820
+
821
+ # ------------------------------------------------------------------------------------------
822
+
823
+ # update the model
824
+ mdl.update(username: 'tester')
825
+
826
+ # creates an SUCCESS of:
827
+ # [USER|UPDATED] #1 - Max
828
+
829
+ # ------------------------------------------------------------------------------------------
830
+
831
+ # update the model again (without any change)
832
+ mdl.update(username: 'tester')
833
+
834
+ # creates an INFO of:
835
+ # [USER|SKIPPED] #1 - Max
836
+ ```
837
+
838
+ ### line(data, opts)
839
+ Prints just a line with data and line-break _(for payloads)_
840
+
841
+ ```ruby
842
+ require 'simple_logger'
843
+ l = SimpleLogger.new(:stdout)
844
+
845
+ l.line "some example line of DATA"
846
+ l.print "other example"
847
+ # > some example line of DATA
848
+ # > other example
849
+ # >
850
+ ```
851
+
852
+ ### print(data, opts)
853
+ Prints just data without line-break
854
+
855
+ ```ruby
856
+ require 'simple_logger'
857
+ l = SimpleLogger.new(:stdout)
858
+
859
+ l.print "some example line of DATA"
860
+ l.print "other example"
861
+ # > some example line of DATAother example
862
+ ```
863
+
864
+
865
+ ### nl(opts)
866
+ Prints just a line-break.
867
+
868
+ ```ruby
869
+ require 'simple_logger'
870
+ l = SimpleLogger.new(:stdout)
871
+
872
+ l.nl
873
+ # >
874
+ # >
875
+ ```
798
876
 
799
877
  -----
800
878
 
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
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
+
6
+ ## [1.6.0] - 2025-06-13
7
+ * **[add]** `Proc` to builtins
8
+ * **[add]** better specs
9
+ * **[ref]** initialization process _(simplify, move instance-assignments to `#initialize`, rename \_opts_x to assign_x)_
10
+ * **[fix]** `Debase.logger` rewriting for Ruby 3.x _(Debase.logger is a proc instead of a Logger / STDOUT)_
11
+
3
12
  ## [1.5.3] - 2024-09-16
4
13
  * **[fix]** scene `job`-, `sub_job`-methods not working with provided block
5
14
  * **[fix]** scene `result`-methods not printing boolean results (also fixes exception for boolean/numeric results)
@@ -13,7 +13,7 @@ module RubySmart
13
13
 
14
14
  # set / overwrite default opts
15
15
  # @param [Hash] opts
16
- def _opts_init!(opts)
16
+ def assign_defaults!(opts)
17
17
  # -- level ---------------------------------------------------------------------------------------------------
18
18
 
19
19
  # initialize a default rails-dependent output
@@ -37,32 +37,17 @@ module RubySmart
37
37
  self.mask(length: ::ThreadInfo.winsize[1])
38
38
  end
39
39
 
40
- # -- instance related ----------------------------------------------------------------------------------------
41
-
42
- # ignore payload and send data directly to the logdev
43
- @ignore_payload = true if @ignore_payload.nil? && opts[:payload] == false
44
-
45
- # ignore processed logging and send data without 'leveling' & PCD-char to the logdev
46
- @ignore_processed = true if @ignore_processed.nil? && opts[:processed] == false
47
-
48
- # ignore tagged logging and send data without 'tags' to the logdev
49
- @ignore_tagged = true if @ignore_tagged.nil? && opts[:tagged] == false
50
-
51
- # set custom inspector (used for data inspection)
52
- # 'disable' inspector, if false was provided - which simply results in +#to_s+
53
- @inspector = (opts[:inspect] == false) ? :to_s : opts[:inspector]
54
-
55
- # prevent to return any data
40
+ # prevent returning any data
56
41
  nil
57
42
  end
58
43
 
59
- # enhance provided opts with +:device+.
44
+ # enhance provided opts with +:logdev+.
60
45
  # opts may be manipulated by resolved device
61
46
  # does not return any data.
62
47
  # @param [Hash] opts
63
- def _opts_device!(opts)
64
- # check for already existing +device+
65
- return if opts[:device]
48
+ def assign_logdev!(opts)
49
+ # check for already existing +logdev+
50
+ return if opts[:logdev]
66
51
 
67
52
  # remove builtin key from opts and force an array
68
53
  builtins = Array(opts.delete(:builtin))
@@ -77,20 +62,23 @@ module RubySmart
77
62
 
78
63
  # don't create multi-device for a single (or +nil+) builtin
79
64
  if builtins.length < 2
80
- opts[:device] = _resolve_device(builtins[0], opts)
65
+ opts[:logdev] = _resolve_device(builtins[0], opts)
81
66
  else
82
- opts[:device] = ::RubySmart::SimpleLogger::Devices::MultiDevice.new
67
+ opts[:logdev] = ::RubySmart::SimpleLogger::Devices::MultiDevice.new
83
68
  builtins.each do |builtin|
84
69
  # IMPORTANT: dup, original hash to prevent reference manipulation (on the TOP-level, only)
85
70
  builtin_opts = opts.dup
86
- opts[:device].register(_resolve_device(builtin, builtin_opts), _resolve_formatter(builtin_opts))
71
+ opts[:logdev].register(_resolve_device(builtin, builtin_opts), _resolve_formatter(builtin_opts))
72
+
73
+ # disable payload, if any is disabled
74
+ opts[:payload] = false if builtin_opts[:payload] == false
87
75
  end
88
76
 
89
77
  # force 'passthrough', as format, since this is required for multi-devices
90
78
  opts[:format] = :passthrough
91
79
  end
92
80
 
93
- # prevent to return any data
81
+ # prevent returning any data
94
82
  nil
95
83
  end
96
84
 
@@ -98,13 +86,13 @@ module RubySmart
98
86
  # opts may be manipulated by resolved formatter
99
87
  # does not return any data.
100
88
  # @param [Hash] opts
101
- def _opts_formatter!(opts)
89
+ def assign_formatter!(opts)
102
90
  # check for already existing +formatter+
103
91
  return if opts[:formatter]
104
92
 
105
93
  opts[:formatter] = _resolve_formatter(opts)
106
94
 
107
- # prevent to return any data
95
+ # prevent returning any data
108
96
  nil
109
97
  end
110
98
 
@@ -115,8 +103,8 @@ module RubySmart
115
103
  # set default format
116
104
  opts[:format] ||= :plain
117
105
 
118
- # fix nl - which depends on other opts
119
- opts[:nl] = _nl(opts)
106
+ # fix nl
107
+ opts[:nl] = true if opts[:nl].nil?
120
108
 
121
109
  # fix clr
122
110
  opts[:clr] = true if opts[:clr].nil?
@@ -125,12 +113,17 @@ module RubySmart
125
113
  end
126
114
 
127
115
  # resolves & returns device from builtin & provided opts
128
- # @param [Object] builtin
116
+ # @param [Object,nil] builtin
129
117
  # @param [Hash] opts
130
118
  def _resolve_device(builtin, opts)
119
+ # in case the provided *builtin* already responds to +write+, return it
120
+ return builtin if builtin.respond_to?(:write)
121
+
131
122
  case builtin
132
123
  when nil # builtin is nil - resolve optimal device for current environment
133
- if ::ThreadInfo.stdout?
124
+ if opts.key?(:device)
125
+ _resolve_device(opts.delete(:device), opts)
126
+ elsif ::ThreadInfo.stdout?
134
127
  _resolve_device(:stdout, opts)
135
128
  elsif ::ThreadInfo.debugger?
136
129
  _resolve_device(:debugger, opts)
@@ -144,7 +137,16 @@ module RubySmart
144
137
  when :debugger
145
138
  raise "Unable to build SimpleLogger with 'debugger' builtin for not initialized Debugger!" unless ThreadInfo.debugger?
146
139
 
147
- _resolve_device(::Debugger.logger, opts)
140
+ # since some IDEs did a Debase rewriting for Ruby 3.x, the logger is a Proc instead of a Logger instance
141
+ if ::Debugger.logger.is_a?(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
146
+ ::RubySmart::SimpleLogger::Devices::ProcDevice.new(::Debugger.logger)
147
+ else
148
+ _resolve_device(::Debugger.logger, opts)
149
+ end
148
150
  when :stdout
149
151
  STDOUT
150
152
  when :stderr
@@ -161,84 +163,105 @@ module RubySmart
161
163
  _resolve_device(::Rails.logger, opts)
162
164
  end
163
165
  when :proc
164
- # force overwrite opts
165
- @ignore_payload = true
166
- opts[:nl] = false
167
- opts[:format] = :passthrough
168
-
169
- ::RubySmart::SimpleLogger::Devices::ProcDevice.new(opts.delete(:proc))
166
+ # slurp the proc and call the '_resolve_device' again
167
+ _resolve_device(opts.delete(:proc), opts)
170
168
  when :memory
171
169
  # force overwrite opts
172
- @ignore_payload = true
173
- opts[:format] = :memory
170
+ opts[:payload] = false
171
+ opts[:format] = :memory
174
172
  # no color logging for memory devices
175
173
  opts[:clr] = false
174
+ # no newline (just for completeness - however the "memory" formatter does NEVER include *nl*)
175
+ opts[:nl] = false
176
176
 
177
177
  ::RubySmart::SimpleLogger::Devices::MemoryDevice.new
178
- when Module, String
178
+ when Proc
179
179
  # force overwrite opts
180
- opts[:clr] = false
181
- _logdev(opts, builtin)
182
- when ::Logger
183
- builtin.instance_variable_get(:@logdev).dev
184
- else
185
- _logdev(opts, builtin)
186
- end
187
- end
188
-
189
- # resolve the final log-device from provided param
190
- # @param [Hash] opts
191
- # @param [Object] device
192
- # @return [:Logger::LogDevice]
193
- def _logdev(opts, device = nil)
194
- device ||= opts.delete(:device)
180
+ opts[:payload] = false
181
+ opts[:nl] = false
182
+ opts[:format] = :passthrough
195
183
 
196
- # if existing device is already writeable, simply return it
197
- return device if device.respond_to?(:write)
184
+ ::RubySmart::SimpleLogger::Devices::ProcDevice.new(builtin)
185
+ when Module
186
+ # no color logging for logfiles
187
+ opts[:clr] = false
198
188
 
199
- file_location = nil
189
+ logfile = _underscore(builtin.to_s) + '.log'
200
190
 
201
- # resolve the file_location from provided device
202
- case device
203
- when Module
204
- devstring = device.to_s
205
- logfile = (devstring.respond_to?(:underscore) ? devstring.underscore : _underscore(device.to_s)) + '.log'
206
- # check for rails
207
- if ::ThreadInfo.rails?
208
- file_location = File.join(Rails.root, 'log', logfile)
209
- else
210
- file_location = File.join('log', logfile)
211
- end
191
+ file_location = if ::ThreadInfo.rails? # check for rails
192
+ File.join(::Rails.root, 'log', logfile)
193
+ else
194
+ File.join('log', logfile)
195
+ end
212
196
 
213
197
  # resolve path to create a folder
214
198
  file_path = File.dirname(file_location)
215
199
  FileUtils.mkdir_p(file_path) unless File.directory?(file_path)
216
200
 
217
- # the logdev
218
- file_location
201
+ # resolve new logdev with the provided options
202
+ _logdev(file_location, opts)
219
203
  when String
220
- file_location = (device[0] == '/' ? device : "log/#{device}")
204
+ # no color logging for logfiles
205
+ opts[:clr] = false
206
+
207
+ logfile = if builtin[-4..-1] == '.log'
208
+ builtin
209
+ else
210
+ builtin + '.log'
211
+ end
212
+
213
+ file_location = if builtin[0] == '/'
214
+ builtin
215
+ elsif ::ThreadInfo.rails?
216
+ File.join(Rails.root, 'log', logfile)
217
+ else
218
+ File.join('log', logfile)
219
+ end
221
220
 
222
221
  # resolve path to create a folder
223
222
  file_path = File.dirname(file_location)
224
223
  FileUtils.mkdir_p(file_path) unless File.directory?(file_path)
225
224
 
226
- file_location
225
+ # resolve new logdev with the provided options
226
+ _logdev(file_location, opts)
227
+ when ::Logger
228
+ # resolve the logdev from the provided logger
229
+ builtin.instance_variable_get(:@logdev).dev
227
230
  else
228
- raise "Unable to build SimpleLogger! The provided device '#{device}' must respond to 'write'!"
231
+ raise "Unable to build SimpleLogger! The provided device '#{builtin}' must respond to 'write'!"
229
232
  end
233
+ end
230
234
 
235
+ # Creates and configures a new instance of Logger::LogDevice based on the provided file location
236
+ # and optional settings.
237
+ #
238
+ # The configuration differs slightly based on the Ruby version being used. For Ruby versions
239
+ # prior to 2.7, the options `:binmode` is omitted as it is not supported. For Ruby 2.7 and newer,
240
+ # the `:binmode` option is included.
241
+ #
242
+ # @param [String] file_location - the file path where the log will be written.
243
+ # @param [Hash] opts
244
+ # A hash of options to configure the log device:
245
+ # - `:shift_age` (default: 0) - Specifies the number of old log files to retain.
246
+ # - `:shift_size` (default: 1048576, 1MB) - Specifies the maximum size of the log file,
247
+ # after which the file will be rotated.
248
+ # - `:shift_period_suffix` - A string specifying the date format for rotated files (optional).
249
+ # - `:binmode` (Ruby >= 2.7 only) - Enables binary mode explicitly if set to `true`.
250
+ #
251
+ # @return [Logger::LogDevice]
252
+ # Returns a newly configured instance of Logger::LogDevice.
253
+ def _logdev(file_location, opts)
231
254
  if GemInfo.match?(RUBY_VERSION, '< 2.7')
232
255
  ::Logger::LogDevice.new(file_location,
233
- shift_age: opts[:shift_age] || 0,
234
- shift_size: opts[:shift_size] || 1048576,
256
+ shift_age: opts[:shift_age] || 0,
257
+ shift_size: opts[:shift_size] || 1048576,
235
258
  shift_period_suffix: opts[:shift_period_suffix])
236
259
  else
237
260
  ::Logger::LogDevice.new(file_location,
238
- shift_age: opts[:shift_age] || 0,
239
- shift_size: opts[:shift_size] || 1048576,
261
+ shift_age: opts[:shift_age] || 0,
262
+ shift_size: opts[:shift_size] || 1048576,
240
263
  shift_period_suffix: opts[:shift_period_suffix],
241
- binmode: opts[:binmode])
264
+ binmode: opts[:binmode])
242
265
  end
243
266
  end
244
267
 
@@ -255,16 +278,6 @@ module RubySmart
255
278
  word
256
279
  end
257
280
 
258
- # returns the +nl+ (new line) flag, depending on the provided options.
259
- # recognizes +:nl+ and +:payload+ options.
260
- # @param [Hash] opts
261
- # @return [Boolean]
262
- def _nl(opts)
263
- return opts[:nl] unless opts[:nl].nil?
264
-
265
- opts[:payload].is_a?(FalseClass)
266
- end
267
-
268
281
  # merge all provided hashes into one single hash
269
282
  #
270
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
@@ -9,8 +9,8 @@ module RubySmart
9
9
 
10
10
  module VERSION
11
11
  MAJOR = 1
12
- MINOR = 5
13
- TINY = 3
12
+ MINOR = 6
13
+ TINY = 1
14
14
  PRE = nil
15
15
 
16
16
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -47,24 +47,44 @@ module RubySmart
47
47
  # @option args[Symbol,Array] <builtin> - provide a builtin, either a single symbol or array of symbols
48
48
  # @option args[Hash] <options> - provide custom options
49
49
  def initialize(*args)
50
+ # transform args to opts
50
51
  opts = args.last.is_a?(Hash) ? args.pop : {}
51
52
  opts[:builtin] = args if args.length > 0
52
53
 
53
- # enhance options with device & formatter
54
- _opts_device!(opts)
55
- _opts_formatter!(opts)
54
+ # assign logdev to opts
55
+ assign_logdev!(opts)
56
56
 
57
- # initialize & set defaults by provided opts
58
- _opts_init!(opts)
57
+ # assign formatter to opts
58
+ assign_formatter!(opts)
59
+
60
+ # assign default opts
61
+ assign_defaults!(opts)
59
62
 
60
63
  # initialize with a nil +logdev+ to prevent any nested +LogDevice+ creation.
61
64
  # we already arranged device & formatter to be able to respond to ther required methods
62
65
  super(nil)
63
66
 
64
- # set explicit after called super
67
+ # level must be set through the *_level* method, to prevent invalid values
65
68
  self.level = opts[:level]
69
+
70
+ # use the provided formatter
66
71
  self.formatter = opts[:formatter]
67
- @logdev = _logdev(opts)
72
+
73
+ # ignore payload and send data directly to the logdev
74
+ @ignore_payload = true if opts[:payload] == false
75
+
76
+ # ignore processed logging and send data without 'leveling' & PCD-char to the logdev
77
+ @ignore_processed = true if opts[:processed] == false
78
+
79
+ # ignore tagged logging and send data without 'tags' to the logdev
80
+ @ignore_tagged = true if opts[:tagged] == false
81
+
82
+ # set custom inspector (used for data inspection)
83
+ # 'disable' inspector, if false was provided - which simply results in +#to_s+
84
+ @inspector = (opts[:inspect] == false) ? :to_s : opts[:inspector]
85
+
86
+ # set resolved logdev
87
+ @logdev = opts[:logdev]
68
88
  end
69
89
 
70
90
  # overwrite level setter, to accept every available (also newly defined) Severity
@@ -85,9 +85,9 @@ module RubySmart
85
85
  # log level @ debug
86
86
  # prints: prettified subject
87
87
  #
88
- # > ===========================================================================================================
89
- # > ================================================ <Subject> ================================================
90
- # > ===========================================================================================================
88
+ # > ========================================================================================================================
89
+ # > ======================================================= <Subject> ======================================================
90
+ # > ========================================================================================================================
91
91
  base.scene :header, { level: :debug, payload: [:mask, [:mask, ' <%{subject}> '], :mask] } do |subject, **opts|
92
92
  # autostart a timer method, if required
93
93
  self.timer(:start, :default) if opts[:timer]
@@ -99,9 +99,9 @@ module RubySmart
99
99
  # log level @ debug
100
100
  # prints: prettified subject
101
101
  #
102
- # > ===========================================================================================================
103
- # > ================================================ >Subject< ================================================
104
- # > ===========================================================================================================
102
+ # > ========================================================================================================================
103
+ # > ======================================================= >Subject< ======================================================
104
+ # > ========================================================================================================================
105
105
  base.scene :footer, { level: :debug, payload: [:mask, [:mask, ' >%{subject}< '], :mask] } do |subject, **opts|
106
106
  self.log nil, _scene_opts(:footer, subject: subject.to_s, **opts)
107
107
 
@@ -113,9 +113,9 @@ module RubySmart
113
113
  # log level @ debug
114
114
  # prints: prettified subject
115
115
  #
116
- # > --------------------------------------------------------------------------------
117
- # > #----------------------------------- Subject ----------------------------------#
118
- # > --------------------------------------------------------------------------------
116
+ # > -----------------------------------------------------------------------------------------------
117
+ # > #------------------------------------------ Subject ------------------------------------------#
118
+ # > -----------------------------------------------------------------------------------------------
119
119
  base.scene :topic, { level: :debug, mask: { char: '-', length: 95, clr: :blueish }, payload: [:mask, [:mask, '%{title}'], :mask] } do |subject, **opts|
120
120
  opts = _scene_opts(:topic, **opts)
121
121
  txt = " #{subject} ".center(opts[:mask][:length] - 2, opts[:mask][:char])
@@ -129,7 +129,7 @@ module RubySmart
129
129
  # prints: prettified, colored subject
130
130
  #
131
131
  # > # Subject
132
- # > ----------------------------------------------------------------------
132
+ # > -------------------------------------------------------------------------------------
133
133
  base.scene :theme, { level: :debug, clr: :purple, mask: { char: '-', length: 85, clr: :purple }, payload: [[:txt, '# %{subject}'], :mask] } do |subject, **opts|
134
134
  self.log nil, _scene_opts(:theme, subject: subject.to_s, **opts)
135
135
  end
@@ -138,7 +138,7 @@ module RubySmart
138
138
  # log level @ debug
139
139
  # prints: prettified, colored result
140
140
  #
141
- # > ----------------------------------------------------------------------
141
+ # > -------------------------------------------------------------------------------------
142
142
  # > -> Result
143
143
  # >
144
144
  base.scene :theme_result, { level: :debug, mask: { char: '-', length: 85, clr: :purple }, payload: [:mask, [:txt, '-> %{result}'], ''] } do |result, status = nil, **opts|
@@ -149,7 +149,7 @@ module RubySmart
149
149
  # log level @ debug
150
150
  # prints: colored line with no text
151
151
  #
152
- # > ----------------------------------------------------------------------
152
+ # > -------------------------------------------------------------------------------------
153
153
  base.scene :theme_line, { level: :debug, mask: { char: '-', length: 85, clr: :purple }, payload: [:mask] } do |**opts|
154
154
  self.log nil, _scene_opts(:theme_line, **opts)
155
155
  end
@@ -170,7 +170,7 @@ module RubySmart
170
170
  # calls the result method if a block was provided
171
171
  #
172
172
  # > - Job name =>
173
- # ________________________________________________________________ <- 64 chars
173
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- 64 chars
174
174
  base.scene :job, { level: :debug, clr: :cyan, nl: false, length: 64, payload: [[:concat, ['- ', [:txt, '%{name}'], ' => ']]] } do |name, **opts, &block|
175
175
  self.log nil, _scene_opts(:job, name: name, **opts)
176
176
  self.result(*block.call) if block
@@ -182,7 +182,7 @@ module RubySmart
182
182
  # calls the result method if a block was provided
183
183
  #
184
184
  # > * Subjob name =>
185
- # ______________________________________________________________ <- 62 chars
185
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- 62 chars
186
186
  base.scene :sub_job, { level: :debug, clr: :cyan, nl: false, length: 62, payload: [[:concat, [' * ', [:txt, '%{name}'], ' => ']]] } do |name, **opts, &block|
187
187
  self.log nil, _scene_opts(:sub_job, name: name, **opts)
188
188
  self.result(*block.call) if block
@@ -331,6 +331,7 @@ module RubySmart
331
331
  end
332
332
  rescue => e
333
333
  self.fatal("#{e.message} @ #{e.backtrace_locations&.first}") unless opts[:silent]
334
+
334
335
  # reraise exception
335
336
  raise
336
337
  ensure
@@ -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,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_smart-simple_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Gonsior
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-09-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: ruby_smart-support
@@ -175,7 +174,6 @@ metadata:
175
174
  documentation_uri: https://rubydoc.info/gems/ruby_smart-simple_logger
176
175
  changelog_uri: https://github.com/ruby-smart/simple_logger/blob/main/docs/CHANGELOG.md
177
176
  allowed_push_host: https://rubygems.org
178
- post_install_message:
179
177
  rdoc_options: []
180
178
  require_paths:
181
179
  - lib
@@ -190,8 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
188
  - !ruby/object:Gem::Version
191
189
  version: '0'
192
190
  requirements: []
193
- rubygems_version: 3.5.14
194
- signing_key:
191
+ rubygems_version: 3.6.9
195
192
  specification_version: 4
196
193
  summary: A simple, multifunctional logging library for Ruby (and Rails).
197
194
  test_files: []