k_log 0.0.30 → 0.0.31

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: 328dd6fd19c8872158c3de15cbcb0bc2cf222ca2124b8d03ce81a81040cd1411
4
- data.tar.gz: f44defe61b5895b2505725c2cbad5c27c45c93e155e25460a85d1a083f1cb775
3
+ metadata.gz: f1791ddbcf6769e1e472c511dd52b4f1d4ddda87c9fba038f8abe17e24bff934
4
+ data.tar.gz: 511ec8d2758769bdc54822f96390f15764e3055f71d96f84db0085b3a8c70a60
5
5
  SHA512:
6
- metadata.gz: 0753d0d203b0673a2526368fa92a6cd6fc0c7ba42f6d425dbaba54b489b9db8e8865bbba2a1b6c22804c6e47b74e1f885b1cb11c85cb9c922fb99d34c30ea21d
7
- data.tar.gz: 436f881ffb78b39ded0f7d2649712286c74c39e104991b8fd28cfc7b7dc7417c91f64030d82ab9a54bb3d17ce6d6ae7c64bfe2ccc955b2ccff6f71b43d5dd72e
6
+ metadata.gz: 680b73d54409a72018e0cbf1ea07df828a86713654afd98fa78739e0b83a8e685eefa14ef56a181529404144b4706c902644a5f96dbf31f79af2abaf893e38e2
7
+ data.tar.gz: 4e855ad037c22b16a3a6ef8bfbbec6b5b3dfee33a35078d4b2f29cc8a2b62ec9d06ae0ea332c8b58f73d19439e5a5e690d18afb62ec4ff3dee4d39d7dc6b27e0
@@ -20,8 +20,10 @@ module KLog
20
20
 
21
21
  msg = msg.is_a?(String) ? msg : msg.inspect
22
22
 
23
+ # "%<time>s %<severity>s %<message>s\n", {
24
+
23
25
  format(
24
- "%<time>s %<severity>s %<message>s\n", {
26
+ "%<severity>s %<message>s\n", {
25
27
  time: Time.now.strftime('%d|%H:%M:%S'),
26
28
  severity: severity_value,
27
29
  message: msg
@@ -36,6 +36,7 @@ module KLog
36
36
  # @option opts [String] :line_width line width defaults to 80, but can be overridden here
37
37
  # @option opts [String] :key_width key width defaults to 30, but can be overridden here
38
38
  # @option opts [String] :formatter is a complex configuration for formatting different data within the structure
39
+ # @option opts [Symbol] :convert_data_to (:raw, open_struct)
39
40
  def initialize(opts)
40
41
  @indent = opts[:indent] || ' '
41
42
  @title = opts[:title]
@@ -119,6 +120,7 @@ module KLog
119
120
 
120
121
  graph_path.push(key)
121
122
  @graph_node = GraphNode.for(self, graph, graph_path)
123
+ # @graph_node.debug
122
124
  # l.kv 'key', "#{key.to_s.ljust(15)}#{graph_node.skip?.to_s.ljust(6)}#{@recursion_depth}"
123
125
 
124
126
  if graph_node.skip?
@@ -127,15 +129,15 @@ module KLog
127
129
  next
128
130
  end
129
131
 
130
- 'puts xmen' if graph_node.pry_at?(:before_value)
132
+ # xxxx.pry if graph_node.pry_at?(:before_value) # 'puts xmen'
131
133
 
132
134
  value = graph_node.transform? ? graph_node.transform(v) : v
133
135
 
134
- 'puts xmen' if graph_node.pry_at?(:after_value)
136
+ # xxxx.pry if graph_node.pry_at?(:after_value) # 'puts xmen'
135
137
  if value.is_a?(OpenStruct) || value.respond_to?(:attributes)
136
138
 
137
139
  # l.kv 'go', 'open struct ->'
138
- 'puts xmen' if graph_node.pry_at?(:before_structure)
140
+ # xxxx.pry if graph_node.pry_at?(:before_structure) # 'puts xmen'
139
141
  log_structure(key, value)
140
142
  # l.kv 'go', 'open struct <-'
141
143
  elsif value.is_a?(Array)
@@ -144,7 +146,7 @@ module KLog
144
146
  # l.kv 'go', 'array <-'
145
147
  else
146
148
  # l.kv 'go', 'value ->'
147
- 'puts xmen' if graph_node.pry_at?(:before_kv)
149
+ # xxxx.pry if graph_node.pry_at?(:before_kv) # 'puts xmen'
148
150
  log_heading(graph_node.heading, graph_node.heading_type) if graph_node.heading
149
151
  add_line KLog::LogHelper.kv("#{@indent_label}#{key}", value, key_width)
150
152
  # l.kv 'go', 'value <-'
@@ -171,14 +173,14 @@ module KLog
171
173
  end
172
174
 
173
175
  def log_array(key, array)
174
- 'puts xmen' if graph_node.pry_at?(:before_array)
176
+ # xxxx.pry if graph_node.pry_at?(:before_array) # 'puts xmen'
175
177
 
176
178
  items = array.clone
177
179
  items.select! { |item| graph_node.filter(item) } if graph_node.filter?
178
180
  items = items.take(graph_node.take) if graph_node.limited?
179
181
  items.sort!(&graph_node.sort) if graph_node.sort?
180
182
 
181
- 'puts xmen' if graph_node.pry_at?(:before_array_print)
183
+ # xxxx.pry if graph_node.pry_at?(:before_array_print) # 'puts xmen'
182
184
 
183
185
  return if items.length.zero? && graph_node.skip_empty?
184
186
 
@@ -344,6 +346,7 @@ module KLog
344
346
 
345
347
  result
346
348
  end
349
+ # puts node_config
347
350
 
348
351
  new(log_structure, node_config)
349
352
  end
@@ -431,6 +434,21 @@ module KLog
431
434
  def show_array_count
432
435
  log_structure.show_array_count
433
436
  end
437
+
438
+ def debug
439
+ l = KLog::LogUtil.new(KLog.logger)
440
+ l.kv('columns', columns) if columns
441
+ l.kv('heading', heading) if heading
442
+ l.kv('heading_type', heading_type) if heading_type
443
+ l.kv('filter?', filter?)
444
+ l.kv('take', take)
445
+ l.kv('limited?', limited?)
446
+ l.kv('sort?', sort?)
447
+ l.kv('sort', sort)
448
+ l.kv('skip?', skip?)
449
+ l.kv('pry_at', pry_at)
450
+ l.kv('skip_empty?', skip_empty?)
451
+ end
434
452
  end
435
453
  end
436
454
  end
@@ -195,12 +195,17 @@ module KLog
195
195
  alias ostruct open_struct
196
196
  alias o open_struct
197
197
 
198
- def exception(exception)
198
+ def exception(exception, short: false, method_info: nil)
199
199
  line
200
200
 
201
201
  @logger.info(KLog::LogHelper.bg_red(exception.message))
202
202
 
203
- @logger.info(KLog::LogHelper.yellow(exception.backtrace.map { |row| row.start_with?(Dir.pwd) ? KLog::LogHelper.yellow(row) : KLog::LogHelper.red(row) }.join("\n")))
203
+ @logger.info([method_info.owner.name, method_info.name].join('#')) if method_info
204
+
205
+ trace_items = short ? exception.backtrace.select { |row| row.start_with?(Dir.pwd) } : exception.backtrace
206
+ trace_items = trace_items.map { |row| row.start_with?(Dir.pwd) ? KLog::LogHelper.yellow(row) : KLog::LogHelper.red(row) }
207
+
208
+ @logger.info(KLog::LogHelper.yellow(trace_items.join("\n")))
204
209
 
205
210
  line
206
211
  end
data/lib/k_log/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KLog
4
- VERSION = '0.0.30'
4
+ VERSION = '0.0.31'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-11 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: k_util