whoop 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -0
- data/README.md +187 -6
- data/Rakefile +1 -0
- data/lib/whoop/formatters/sql_formatter.rb +40 -1
- data/lib/whoop/version.rb +1 -1
- data/lib/whoop.rb +42 -7
- data/sig/whoop.rbs +15 -1
- data/whoop.gemspec +2 -2
- metadata +34 -8
- data/cc-test-reporter +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9b6642d169f36ac114748f02515b804646a7981f244475c41fa053456d93c08
|
4
|
+
data.tar.gz: ca2a36f9da6922d998189ea808bd3976684e3cf2919fb7c4ed9672408591fce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eee07b43704595c415ec3eb4e36cf5ea2b9215982d22f7f5f1d0e7e9565c408dbaa4e41f43385c79c8089f1740907c2c21d8a2bcd9b5d74f64f103433774446a
|
7
|
+
data.tar.gz: 4865c548afe2113e7218ebde457eea291f9152c3bcecae84d684581e4ad9c397b6af965668623d4f581a571062881759d5681a6475cb570f04d9571f224b8eed
|
data/Gemfile.lock
CHANGED
@@ -25,12 +25,15 @@ GEM
|
|
25
25
|
ast (2.4.2)
|
26
26
|
bump (0.10.0)
|
27
27
|
byebug (11.1.3)
|
28
|
+
codecov (0.6.0)
|
29
|
+
simplecov (>= 0.15, < 0.22)
|
28
30
|
coderay (1.1.3)
|
29
31
|
colorize (0.8.1)
|
30
32
|
commander (4.6.0)
|
31
33
|
highline (~> 2.0.0)
|
32
34
|
concurrent-ruby (1.1.10)
|
33
35
|
diff-lcs (1.5.0)
|
36
|
+
docile (1.4.0)
|
34
37
|
highline (2.0.3)
|
35
38
|
i18n (1.12.0)
|
36
39
|
concurrent-ruby (~> 1.0)
|
@@ -86,6 +89,11 @@ GEM
|
|
86
89
|
rubocop (>= 1.7.0, < 2.0)
|
87
90
|
rubocop-ast (>= 0.4.0)
|
88
91
|
ruby-progressbar (1.11.0)
|
92
|
+
simplecov (0.16.1)
|
93
|
+
docile (~> 1.1)
|
94
|
+
json (>= 1.8, < 3)
|
95
|
+
simplecov-html (~> 0.10.0)
|
96
|
+
simplecov-html (0.10.2)
|
89
97
|
sorbet-runtime (0.5.10455)
|
90
98
|
sord (4.0.0)
|
91
99
|
commander (~> 4.5)
|
@@ -104,13 +112,16 @@ GEM
|
|
104
112
|
|
105
113
|
PLATFORMS
|
106
114
|
arm64-darwin-21
|
115
|
+
x86_64-linux
|
107
116
|
|
108
117
|
DEPENDENCIES
|
109
118
|
bump
|
119
|
+
codecov
|
110
120
|
magic_frozen_string_literal
|
111
121
|
pry-byebug
|
112
122
|
rake
|
113
123
|
rspec
|
124
|
+
simplecov
|
114
125
|
sord
|
115
126
|
standard
|
116
127
|
whoop!
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Whoop
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/whoop.svg)](https://badge.fury.io/rb/whoop)
|
4
|
+
[![Contribute](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/coderberry/whoop)
|
4
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/1ffd27fe59383a4ff52b/maintainability)](https://codeclimate.com/github/coderberry/whoop/maintainability)
|
5
|
-
[![
|
6
|
+
[![codecov](https://codecov.io/gh/coderberry/whoop/branch/main/graph/badge.svg?token=E906B6SEKD)](https://codecov.io/gh/coderberry/whoop)
|
6
7
|
[![Tests](https://github.com/coderberry/whoop/actions/workflows/tests.yml/badge.svg)](https://github.com/coderberry/whoop/actions/workflows/tests.yml)
|
7
8
|
[![CodeQL](https://github.com/coderberry/whoop/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/coderberry/whoop/actions/workflows/codeql-analysis.yml)
|
8
9
|
[![StandardRB](https://github.com/coderberry/whoop/actions/workflows/standardrb.yml/badge.svg)](https://github.com/coderberry/whoop/actions/workflows/standardrb.yml)
|
@@ -13,6 +14,8 @@
|
|
13
14
|
|
14
15
|
Whoop is a Ruby logging library with built-in formatting and colorization.
|
15
16
|
|
17
|
+
To try **whoop** within your browser, visit the [whoop playground](https://replit.com/@coderberry/whoop-playground).
|
18
|
+
|
16
19
|
## Installation
|
17
20
|
|
18
21
|
Install the gem and add to the application's Gemfile by executing:
|
@@ -34,7 +37,7 @@ Whoop.setup do |config|
|
|
34
37
|
# config.logger = ActiveSupport::Logger.new("log/#{Rails.env}.log")
|
35
38
|
# config.logger = ActiveSupport::Logger.new($stdout)
|
36
39
|
# config.logger = nil # uses `puts`
|
37
|
-
|
40
|
+
|
38
41
|
config.level = :debug
|
39
42
|
# config.level = :info
|
40
43
|
# config.level = :warn
|
@@ -50,11 +53,189 @@ The `whoop` method is accessible from any object. See specs for more examples.
|
|
50
53
|
whoop "Hello, World!"
|
51
54
|
```
|
52
55
|
|
53
|
-
|
54
|
-
|
56
|
+
You can pass any options into the `whoop` method to change the output.
|
57
|
+
|
58
|
+
- `label` (first argument) - Either the object or title if a block is passed (see below)
|
59
|
+
- `pattern` - String character to use for the line (default is `-`)
|
60
|
+
- `count` - the number of times to repeat the pattern per line (e.g. 80)
|
61
|
+
- `color` - the color to use for the line (e.g. :red)
|
62
|
+
- `format` - the format to use for the message (one of `:json`, `:sql`, `:plain`)
|
63
|
+
- `caller_depth` - the depth of the caller to use for the source (default: 0)
|
64
|
+
- `explain` - whether to run `EXPLAIN` on the SQL query (default: false)
|
65
|
+
- `context` - a hash of key/value pairs to include in the output
|
66
|
+
|
67
|
+
## Examples
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
whoop "Hello"
|
71
|
+
|
72
|
+
# log/debug.log
|
73
|
+
# ┏--------------------------------------------------------------------------------
|
74
|
+
# ┆ timestamp: 2022-09-26 14:28:06 -0600
|
75
|
+
# ┆ source: /spec/whoop_spec.rb:12
|
76
|
+
#
|
77
|
+
# Hello
|
78
|
+
#
|
79
|
+
# ┗--------------------------------------------------------------------------------
|
80
|
+
```
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
whoop("My Label", color: :green) { "Hello" }
|
84
|
+
|
85
|
+
# log/debug.log (the colors don't appear in markdown)
|
86
|
+
# ┏------------------------------------ My Label ------------------------------------
|
87
|
+
# ┆ timestamp: 2022-09-26 14:28:06 -0600
|
88
|
+
# ┆ source: /spec/whoop_spec.rb:26
|
89
|
+
#
|
90
|
+
# Hello
|
91
|
+
#
|
92
|
+
# ┗--------------------------------------------------------------------------------
|
93
|
+
```
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
whoop({hello: "world"}, format: :json, color: false)
|
97
|
+
|
98
|
+
# ┏--------------------------------------------------------------------------------
|
99
|
+
# ┆ timestamp: 2022-09-26 14:28:06 -0600
|
100
|
+
# ┆ source: /spec/whoop_spec.rb:39
|
101
|
+
#
|
102
|
+
# {
|
103
|
+
# "hello": "world"
|
104
|
+
# }
|
105
|
+
#
|
106
|
+
# ┗--------------------------------------------------------------------------------
|
107
|
+
```
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
whoop("This message includes context", color: false, context: {user: "Eric", ip_address: "127.0.0.1"})
|
111
|
+
|
112
|
+
# ┏--------------------------------------------------------------------------------
|
113
|
+
# ┆ timestamp: 2022-09-26 14:28:06 -0600
|
114
|
+
# ┆ source: /spec/whoop_spec.rb:39
|
115
|
+
# ┆ user: Eric
|
116
|
+
# ┆ ip_address: 127.0.0.1
|
117
|
+
#
|
118
|
+
# This message includes context
|
119
|
+
#
|
120
|
+
# ┗--------------------------------------------------------------------------------
|
121
|
+
```
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
sql = 'SELECT emp_id, first_name,last_name,dept_id,mgr_id, ' +
|
125
|
+
'WIDTH_BUCKET(department_id,20,40,10) "Exists in Dept" ' +
|
126
|
+
'FROM emp WHERE mgr_id < 300 ORDER BY "Exists in Dept"'
|
127
|
+
|
128
|
+
whoop(sql, format: :sql)
|
129
|
+
|
130
|
+
# ┏--------------------------------------------------------------------------------
|
131
|
+
# ┆ timestamp: 2022-09-26 14:28:06 -0600
|
132
|
+
# ┆ source: /spec/whoop_spec.rb:52
|
133
|
+
#
|
134
|
+
# SELECT
|
135
|
+
# emp_id
|
136
|
+
# ,first_name
|
137
|
+
# ,last_name
|
138
|
+
# ,dept_id
|
139
|
+
# ,mgr_id
|
140
|
+
# ,WIDTH_BUCKET (
|
141
|
+
# department_id
|
142
|
+
# ,20
|
143
|
+
# ,40
|
144
|
+
# ,10
|
145
|
+
# ) "Exists in Dept"
|
146
|
+
# FROM
|
147
|
+
# emp
|
148
|
+
# WHERE
|
149
|
+
# mgr_id < 300
|
150
|
+
# ORDER BY
|
151
|
+
# "Exists in Dept"
|
152
|
+
#
|
153
|
+
# ┗--------------------------------------------------------------------------------
|
154
|
+
```
|
155
|
+
|
156
|
+
#### Auto-explain SQL queries
|
157
|
+
|
158
|
+
In addition to formatting the SQL query, you can also ask whoop to perform an
|
159
|
+
`explain` on the query by using the `explain: true` argument.
|
160
|
+
|
161
|
+
Example (using the Example 1 sample plan from explain.dalibo.com):
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
sql = <<~SQL
|
165
|
+
SELECT rel_users_exams.user_username AS rel_users_exams_user_username,
|
166
|
+
rel_users_exams.exam_id AS rel_users_exams_exam_id,
|
167
|
+
rel_users_exams.started_at AS rel_users_exams_started_at,
|
168
|
+
rel_users_exams.finished_at AS rel_users_exams_finished_at,
|
169
|
+
exam_1.id AS exam_1_id,
|
170
|
+
exam_1.title AS exam_1_title,
|
171
|
+
exam_1.date_from AS exam_1_date_from,
|
172
|
+
exam_1.date_to AS exam_1_date_to,
|
173
|
+
exam_1.created AS exam_1_created,
|
174
|
+
exam_1.created_by_ AS exam_1_created_by_,
|
175
|
+
exam_1.duration AS exam_1_duration,
|
176
|
+
exam_1.success_threshold AS exam_1_success_threshold,
|
177
|
+
exam_1.published AS exam_1_published
|
178
|
+
FROM rel_users_exams LEFT OUTER
|
179
|
+
JOIN exam AS exam_1
|
180
|
+
ON exam_1.id = rel_users_exams.exam_id
|
181
|
+
WHERE 1 = rel_users_exams.exam_id;
|
182
|
+
SQL
|
183
|
+
|
184
|
+
whoop("SQL with Explain", format: :sql, explain: true) { sql }
|
185
|
+
|
186
|
+
# ┏-------------------------------- SQL with Explain --------------------------------
|
187
|
+
# ┆ timestamp: 2022-09-26 14:50:11 -0600
|
188
|
+
# ┆ source: (irb):23:in `<top (required)>'
|
189
|
+
#
|
190
|
+
# sql:
|
191
|
+
#
|
192
|
+
# SELECT
|
193
|
+
# rel_users_exams.user_username AS rel_users_exams_user_username
|
194
|
+
# ,rel_users_exams.exam_id AS rel_users_exams_exam_id
|
195
|
+
# ,rel_users_exams.started_at AS rel_users_exams_started_at
|
196
|
+
# ,rel_users_exams.finished_at AS rel_users_exams_finished_at
|
197
|
+
# ,exam_1.id AS exam_1_id
|
198
|
+
# ,exam_1.title AS exam_1_title
|
199
|
+
# ,exam_1.date_from AS exam_1_date_from
|
200
|
+
# ,exam_1.date_to AS exam_1_date_to
|
201
|
+
# ,exam_1.created AS exam_1_created
|
202
|
+
# ,exam_1.created_by_ AS exam_1_created_by_
|
203
|
+
# ,exam_1.duration AS exam_1_duration
|
204
|
+
# ,exam_1.success_threshold AS exam_1_success_threshold
|
205
|
+
# ,exam_1.published AS exam_1_published
|
206
|
+
# FROM
|
207
|
+
# rel_users_exams LEFT OUTER JOIN exam AS exam_1
|
208
|
+
# ON exam_1.id = rel_users_exams.exam_id
|
209
|
+
# WHERE
|
210
|
+
# 1 = rel_users_exams.exam_id
|
211
|
+
# ;
|
212
|
+
#
|
213
|
+
# query plan:
|
214
|
+
#
|
215
|
+
# Nested Loop Left Join (cost=11.95..28.52 rows=5 width=157) (actual time=0.010..0.010 rows=0 loops=1)
|
216
|
+
# Output: rel_users_exams.user_username, rel_users_exams.exam_id, rel_users_exams.started_at, rel_users_exams.finished_at, exam_1.id, exam_1.title, exam_1.date_from, exam_1.date_to, exam_1.created, exam_1.created_by_, exam_1.duration, exam_1.success_threshold, exam_1.published
|
217
|
+
# Inner Unique: true
|
218
|
+
# Join Filter: (exam_1.id = rel_users_exams.exam_id)
|
219
|
+
# Buffers: shared hit=1
|
220
|
+
# -> Bitmap Heap Scan on public.rel_users_exams (cost=11.80..20.27 rows=5 width=52) (actual time=0.009..0.009 rows=0 loops=1)
|
221
|
+
# Output: rel_users_exams.user_username, rel_users_exams.exam_id, rel_users_exams.started_at, rel_users_exams.finished_at
|
222
|
+
# Recheck Cond: (1 = rel_users_exams.exam_id)
|
223
|
+
# Buffers: shared hit=1
|
224
|
+
# -> Bitmap Index Scan on rel_users_exams_pkey (cost=0.00..11.80 rows=5 width=0) (actual time=0.005..0.005 rows=0 loops=1)
|
225
|
+
# Index Cond: (1 = rel_users_exams.exam_id)
|
226
|
+
# Buffers: shared hit=1
|
227
|
+
# -> Materialize (cost=0.15..8.17 rows=1 width=105) (never executed)
|
228
|
+
# Output: exam_1.id, exam_1.title, exam_1.date_from, exam_1.date_to, exam_1.created, exam_1.created_by_, exam_1.duration, exam_1.success_threshold, exam_1.published
|
229
|
+
# -> Index Scan using exam_pkey on public.exam exam_1 (cost=0.15..8.17 rows=1 width=105) (never executed)
|
230
|
+
# Output: exam_1.id, exam_1.title, exam_1.date_from, exam_1.date_to, exam_1.created, exam_1.created_by_, exam_1.duration,
|
231
|
+
# exam_1.success_threshold, exam_1.published
|
232
|
+
# Index Cond: (exam_1.id = 1)
|
233
|
+
# Planning Time: 1.110 ms
|
234
|
+
# Execution Time: 0.170 ms
|
235
|
+
#
|
236
|
+
# ┗--------------------------------------------------------------------------------
|
237
|
+
```
|
55
238
|
|
56
|
-
### Colors
|
57
|
-
TODO
|
58
239
|
|
59
240
|
## Development
|
60
241
|
|
data/Rakefile
CHANGED
@@ -6,6 +6,33 @@ require "active_record"
|
|
6
6
|
module Whoop
|
7
7
|
module Formatters
|
8
8
|
module SqlFormatter
|
9
|
+
# Hash of patterns to preserve in the SQL. The key is the expected pattern,
|
10
|
+
# the value is the pattern after it has been "broken" by anbt formatting.
|
11
|
+
# Instances of the value are replaced by the key.
|
12
|
+
# Patterns are jsonb column operators from https://www.postgresql.org/docs/15/functions-json.html
|
13
|
+
PATTERNS_TO_PRESERVE = {
|
14
|
+
# jsonb operators without surrounding spaces
|
15
|
+
# IE, the first one replaces " : : " with "::"
|
16
|
+
"::" => /\s?: :\s?/,
|
17
|
+
"->>" => /\s?- > >\s?/,
|
18
|
+
"->" => /\s?- >\s?/,
|
19
|
+
"#>>" => /\s?# > >\s?/,
|
20
|
+
"#>" => /\s?# >\s?/,
|
21
|
+
|
22
|
+
# jsonb operators with surrounding spaces
|
23
|
+
# IE, the first one replaces " @ > " with " @> "
|
24
|
+
" @> " => /\s?@ >\s?/,
|
25
|
+
" <@ " => /\s?< @\s?/,
|
26
|
+
" ?| " => /\s?\? \|\s?/,
|
27
|
+
" ?& " => /\s?\? &\s?/,
|
28
|
+
" || " => /\s?\| \|\s?/,
|
29
|
+
" #- " => /\s?# -\s?/,
|
30
|
+
|
31
|
+
# Additional broken patterns
|
32
|
+
"[" => /\[\s?/,
|
33
|
+
"]" => /\s?\]/
|
34
|
+
}
|
35
|
+
|
9
36
|
# Format the SQL query
|
10
37
|
# @param [String] sql The SQL query
|
11
38
|
# @param [Boolean] colorize - colorize the SQL query (default: false)
|
@@ -39,8 +66,20 @@ module Whoop
|
|
39
66
|
def self.generate_pretty_sql(sql)
|
40
67
|
rule = AnbtSql::Rule.new
|
41
68
|
rule.indent_string = " "
|
69
|
+
|
42
70
|
formatter = AnbtSql::Formatter.new(rule)
|
43
|
-
formatter.format(sql.dup)
|
71
|
+
formatted_string = formatter.format(sql.dup)
|
72
|
+
|
73
|
+
# Anbt injects additional spaces into joined symbols.
|
74
|
+
# This removes them by generating the "broken" collection
|
75
|
+
# of symbols, and replacing them with the original.
|
76
|
+
PATTERNS_TO_PRESERVE.each do |correct_pattern, incorrect_pattern|
|
77
|
+
next unless incorrect_pattern.match?(formatted_string)
|
78
|
+
|
79
|
+
formatted_string.gsub!(incorrect_pattern, correct_pattern)
|
80
|
+
end
|
81
|
+
|
82
|
+
formatted_string
|
44
83
|
end
|
45
84
|
|
46
85
|
# Execute the `EXPLAIN` query
|
data/lib/whoop/version.rb
CHANGED
data/lib/whoop.rb
CHANGED
@@ -30,6 +30,9 @@ module Whoop
|
|
30
30
|
FORMATS = %i[plain json sql].freeze
|
31
31
|
PATTERN = "-"
|
32
32
|
COUNT = 80
|
33
|
+
INDENT = "┆"
|
34
|
+
TOP_LINE_CHAR = "┏"
|
35
|
+
BOTTOM_LINE_CHAR = "┗"
|
33
36
|
|
34
37
|
# Log the message to the logger
|
35
38
|
# @param [String] label (optional) - the label or object to log
|
@@ -39,15 +42,34 @@ module Whoop
|
|
39
42
|
# @param [Symbol] format - the format to use for the message (one of :json, :sql, :plain)
|
40
43
|
# @param [Integer] caller_depth - the depth of the caller to use for the source (default: 0)
|
41
44
|
# @param [Boolean] explain - whether to explain the SQL query (default: false)
|
42
|
-
|
45
|
+
# @param [Hash] context - Any additional context you'd like to include in the log
|
46
|
+
def whoop(
|
47
|
+
label = nil,
|
48
|
+
pattern: PATTERN,
|
49
|
+
count: COUNT,
|
50
|
+
color: :default,
|
51
|
+
format: :plain,
|
52
|
+
caller_depth: 0,
|
53
|
+
explain: false,
|
54
|
+
context: nil
|
55
|
+
)
|
43
56
|
logger_method = detect_logger_method
|
44
57
|
color_method = detect_color_method(color)
|
45
58
|
formatter_method = detect_formatter_method(format, colorize: color.present?, explain: explain)
|
46
59
|
|
47
60
|
line = pattern * count
|
48
61
|
caller_path = clean_caller_path(caller[caller_depth])
|
49
|
-
caller_path_line = ["source:".colorize(:light_black).underline, caller_path].join(" ")
|
50
|
-
timestamp_line = ["timestamp:".colorize(:light_black).underline, Time.now].join(" ")
|
62
|
+
caller_path_line = [color_method.call(INDENT), "source:".colorize(:light_black).underline, caller_path].join(" ")
|
63
|
+
timestamp_line = [color_method.call(INDENT), "timestamp:".colorize(:light_black).underline, Time.now].join(" ")
|
64
|
+
|
65
|
+
context_lines =
|
66
|
+
if context.is_a?(Hash) && context.keys.length > 0
|
67
|
+
context.map do |k, v|
|
68
|
+
[color_method.call(INDENT), "#{k}:".colorize(:light_black).underline, v].join(" ")
|
69
|
+
end
|
70
|
+
else
|
71
|
+
[]
|
72
|
+
end
|
51
73
|
|
52
74
|
if block_given?
|
53
75
|
result = yield
|
@@ -58,21 +80,27 @@ module Whoop
|
|
58
80
|
pattern * count
|
59
81
|
end
|
60
82
|
result.tap do
|
61
|
-
logger_method.call color_method.call "\n\n#{top_line}"
|
83
|
+
logger_method.call color_method.call "\n\n#{TOP_LINE_CHAR}#{top_line}"
|
62
84
|
logger_method.call timestamp_line
|
63
85
|
logger_method.call caller_path_line
|
86
|
+
context_lines.each { |l| logger_method.call l }
|
64
87
|
logger_method.call ""
|
65
88
|
logger_method.call formatter_method.call(result)
|
66
|
-
logger_method.call
|
89
|
+
logger_method.call ""
|
90
|
+
display_invalid_format_message(format, color_method, logger_method)
|
91
|
+
logger_method.call color_method.call "#{BOTTOM_LINE_CHAR}#{line}\n\n"
|
67
92
|
end
|
68
93
|
else
|
69
94
|
tap do
|
70
|
-
logger_method.call color_method.call "\n\n#{line}"
|
95
|
+
logger_method.call color_method.call "\n\n#{TOP_LINE_CHAR}#{line}"
|
71
96
|
logger_method.call timestamp_line
|
72
97
|
logger_method.call caller_path_line
|
98
|
+
context_lines.each { |l| logger_method.call l }
|
73
99
|
logger_method.call ""
|
74
100
|
logger_method.call formatter_method.call(label)
|
75
|
-
logger_method.call
|
101
|
+
logger_method.call ""
|
102
|
+
display_invalid_format_message(format, color_method, logger_method)
|
103
|
+
logger_method.call color_method.call "#{BOTTOM_LINE_CHAR}#{line}\n\n"
|
76
104
|
end
|
77
105
|
end
|
78
106
|
end
|
@@ -124,6 +152,13 @@ module Whoop
|
|
124
152
|
end
|
125
153
|
end
|
126
154
|
|
155
|
+
def display_invalid_format_message(format, color_method, logger_method)
|
156
|
+
return if FORMATS.include?(format)
|
157
|
+
|
158
|
+
invalid_format_line = [color_method.call(INDENT), "note:".colorize(:blue).underline, "Unsupported format used. Available formats: #{FORMATS.to_sentence}"].join(" ")
|
159
|
+
logger_method.call invalid_format_line
|
160
|
+
end
|
161
|
+
|
127
162
|
# Return the line with the label centered in it
|
128
163
|
# @param [String] label
|
129
164
|
# @param [Integer] count
|
data/sig/whoop.rbs
CHANGED
@@ -14,6 +14,9 @@ module Whoop
|
|
14
14
|
FORMATS: untyped
|
15
15
|
PATTERN: untyped
|
16
16
|
COUNT: untyped
|
17
|
+
INDENT: untyped
|
18
|
+
TOP_LINE_CHAR: untyped
|
19
|
+
BOTTOM_LINE_CHAR: untyped
|
17
20
|
|
18
21
|
# sord omit - no YARD return type given, using untyped
|
19
22
|
# Log the message to the logger
|
@@ -31,6 +34,8 @@ module Whoop
|
|
31
34
|
# _@param_ `caller_depth` — - the depth of the caller to use for the source (default: 0)
|
32
35
|
#
|
33
36
|
# _@param_ `explain` — - whether to explain the SQL query (default: false)
|
37
|
+
#
|
38
|
+
# _@param_ `context` — - Any additional context you'd like to include in the log
|
34
39
|
def whoop: (
|
35
40
|
?String? label,
|
36
41
|
?pattern: String,
|
@@ -38,7 +43,8 @@ module Whoop
|
|
38
43
|
?color: Symbol,
|
39
44
|
?format: Symbol,
|
40
45
|
?caller_depth: Integer,
|
41
|
-
?explain: bool
|
46
|
+
?explain: bool,
|
47
|
+
?context: ::Hash[untyped, untyped]?
|
42
48
|
) -> untyped
|
43
49
|
|
44
50
|
# Remove the Rails.root from the caller path
|
@@ -67,6 +73,12 @@ module Whoop
|
|
67
73
|
# _@return_ — format method
|
68
74
|
def detect_formatter_method: (Symbol format, ?colorize: untyped, ?explain: untyped) -> Method
|
69
75
|
|
76
|
+
# sord omit - no YARD type given for "format", using untyped
|
77
|
+
# sord omit - no YARD type given for "color_method", using untyped
|
78
|
+
# sord omit - no YARD type given for "logger_method", using untyped
|
79
|
+
# sord omit - no YARD return type given, using untyped
|
80
|
+
def display_invalid_format_message: (untyped format, untyped color_method, untyped logger_method) -> untyped
|
81
|
+
|
70
82
|
# Return the line with the label centered in it
|
71
83
|
#
|
72
84
|
# _@param_ `label`
|
@@ -79,6 +91,8 @@ module Whoop
|
|
79
91
|
|
80
92
|
module Formatters
|
81
93
|
module SqlFormatter
|
94
|
+
PATTERNS_TO_PRESERVE: untyped
|
95
|
+
|
82
96
|
# Format the SQL query
|
83
97
|
#
|
84
98
|
# _@param_ `sql` — The SQL query
|
data/whoop.gemspec
CHANGED
@@ -14,8 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
16
16
|
|
17
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
-
|
19
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
21
19
|
spec.metadata["changelog_uri"] = spec.homepage
|
@@ -44,4 +42,6 @@ Gem::Specification.new do |spec|
|
|
44
42
|
spec.add_development_dependency "standard"
|
45
43
|
spec.add_development_dependency "bump"
|
46
44
|
spec.add_development_dependency "sord"
|
45
|
+
spec.add_development_dependency "simplecov"
|
46
|
+
spec.add_development_dependency "codecov"
|
47
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Berry
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -178,6 +178,34 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: simplecov
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: codecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
181
209
|
description: A simple gem to help you whoop your logs into shape.
|
182
210
|
email:
|
183
211
|
- eric@berry.sh
|
@@ -194,7 +222,6 @@ files:
|
|
194
222
|
- LICENSE.txt
|
195
223
|
- README.md
|
196
224
|
- Rakefile
|
197
|
-
- cc-test-reporter
|
198
225
|
- lib/whoop.rb
|
199
226
|
- lib/whoop/formatters/json_formatter.rb
|
200
227
|
- lib/whoop/formatters/sql_formatter.rb
|
@@ -205,11 +232,10 @@ homepage: https://github.com/coderberry/whoop
|
|
205
232
|
licenses:
|
206
233
|
- MIT
|
207
234
|
metadata:
|
208
|
-
allowed_push_host: https://rubygems.org
|
209
235
|
homepage_uri: https://github.com/coderberry/whoop
|
210
236
|
source_code_uri: https://github.com/coderberry/whoop
|
211
237
|
changelog_uri: https://github.com/coderberry/whoop
|
212
|
-
post_install_message:
|
238
|
+
post_install_message:
|
213
239
|
rdoc_options: []
|
214
240
|
require_paths:
|
215
241
|
- lib
|
@@ -224,8 +250,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
250
|
- !ruby/object:Gem::Version
|
225
251
|
version: '0'
|
226
252
|
requirements: []
|
227
|
-
rubygems_version: 3.
|
228
|
-
signing_key:
|
253
|
+
rubygems_version: 3.4.6
|
254
|
+
signing_key:
|
229
255
|
specification_version: 4
|
230
256
|
summary: A simple gem to help you whoop your logs into shape.
|
231
257
|
test_files: []
|
data/cc-test-reporter
DELETED
Binary file
|