twiglet 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql-analysis.yml +3 -3
- data/.github/workflows/project-board.yml +17 -0
- data/.github/workflows/version-forget-me-not.yml +1 -1
- data/lib/twiglet/logger.rb +31 -10
- data/lib/twiglet/version.rb +1 -1
- data/test/logger_test.rb +34 -0
- data/twiglet.gemspec +0 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65882a52b10620b9a6ab5ff439b9f377e135308055618474510f232d14be0ec5
|
4
|
+
data.tar.gz: 97fb56dced537bc5bf3e0ddebfc6cf2be076466241eaef4b63437a278664fe47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09a38113c797bec07068cd08a3d2c00fceac2f1617956ce88cb775c8c2fb86344377569f0df5b75d47e93ab8bc1a6c94fadd6d2ec2190edfcefc0d648a471f67'
|
7
|
+
data.tar.gz: e37658db9af2be233a93c3f6ef7ea776a4ae51bbbbd09afb85a5e77c5b13a7172fd7ca141b87241edb1ebf7678f7a4ca1485629a6ef97c7921da7b9a33b32009
|
@@ -42,7 +42,7 @@ jobs:
|
|
42
42
|
|
43
43
|
# Initializes the CodeQL tools for scanning.
|
44
44
|
- name: Initialize CodeQL
|
45
|
-
uses: github/codeql-action/init@
|
45
|
+
uses: github/codeql-action/init@v2
|
46
46
|
with:
|
47
47
|
languages: ${{ matrix.language }}
|
48
48
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
@@ -53,7 +53,7 @@ jobs:
|
|
53
53
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
54
|
# If this step fails, then you should remove it and run the build manually (see below)
|
55
55
|
- name: Autobuild
|
56
|
-
uses: github/codeql-action/autobuild@
|
56
|
+
uses: github/codeql-action/autobuild@v2
|
57
57
|
|
58
58
|
# ℹ️ Command-line programs to run using the OS shell.
|
59
59
|
# 📚 https://git.io/JvXDl
|
@@ -67,4 +67,4 @@ jobs:
|
|
67
67
|
# make release
|
68
68
|
|
69
69
|
- name: Perform CodeQL Analysis
|
70
|
-
uses: github/codeql-action/analyze@
|
70
|
+
uses: github/codeql-action/analyze@v2
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: Automatically add new Issues to Silversmith's GitHub project board
|
2
|
+
# https://github.com/orgs/simplybusiness/projects/3
|
3
|
+
# New issues in this repository will be added to the board.
|
4
|
+
on:
|
5
|
+
issues:
|
6
|
+
types: [ opened, reopened ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
track_issues:
|
10
|
+
uses: simplybusiness/github-action-reusable-workflows/.github/workflows/project-board.yaml@master
|
11
|
+
with:
|
12
|
+
pr-id: ${{ github.event.issue.node_id }}
|
13
|
+
project-number: 3
|
14
|
+
org: simplybusiness
|
15
|
+
actor: ${{ github.actor }}
|
16
|
+
secrets:
|
17
|
+
github-token: ${{ secrets.SILVERSMITHS_PROJECT_MANAGEMENT }}
|
data/lib/twiglet/logger.rb
CHANGED
@@ -42,17 +42,26 @@ module Twiglet
|
|
42
42
|
@validator.custom_error_handler = block
|
43
43
|
end
|
44
44
|
|
45
|
+
def debug(message_or_error = nil, &block)
|
46
|
+
message = message_or_error.is_a?(Exception) ? error_message(message_or_error) : message_or_error
|
47
|
+
|
48
|
+
super(message, &block)
|
49
|
+
end
|
50
|
+
|
51
|
+
def info(message_or_error = nil, &block)
|
52
|
+
message = message_or_error.is_a?(Exception) ? error_message(message_or_error) : message_or_error
|
53
|
+
|
54
|
+
super(message, &block)
|
55
|
+
end
|
56
|
+
|
57
|
+
def warn(message_or_error = nil, &block)
|
58
|
+
message = message_or_error.is_a?(Exception) ? error_message(message_or_error) : message_or_error
|
59
|
+
|
60
|
+
super(message, &block)
|
61
|
+
end
|
62
|
+
|
45
63
|
def error(message = nil, error = nil, &block)
|
46
|
-
if error
|
47
|
-
error_fields = {
|
48
|
-
error: {
|
49
|
-
type: error.class.to_s,
|
50
|
-
message: error.message
|
51
|
-
}
|
52
|
-
}
|
53
|
-
add_stack_trace(error_fields, error)
|
54
|
-
message = Message.new(message).merge(error_fields)
|
55
|
-
end
|
64
|
+
message = error_message(error, message) if error
|
56
65
|
|
57
66
|
super(message, &block)
|
58
67
|
end
|
@@ -76,6 +85,18 @@ module Twiglet
|
|
76
85
|
|
77
86
|
private
|
78
87
|
|
88
|
+
def error_message(error, message = nil)
|
89
|
+
error_fields = {
|
90
|
+
error: {
|
91
|
+
type: error.class.to_s,
|
92
|
+
message: error.message
|
93
|
+
}
|
94
|
+
}
|
95
|
+
add_stack_trace(error_fields, error)
|
96
|
+
message = error.message if message.nil? || message.empty?
|
97
|
+
Message.new(message).merge(error_fields)
|
98
|
+
end
|
99
|
+
|
79
100
|
def add_stack_trace(hash_to_add_to, error)
|
80
101
|
hash_to_add_to[:error][:stack_trace] = error.backtrace if error.backtrace
|
81
102
|
end
|
data/lib/twiglet/version.rb
CHANGED
data/test/logger_test.rb
CHANGED
@@ -361,6 +361,31 @@ describe Twiglet::Logger do
|
|
361
361
|
|
362
362
|
assert_equal 'StandardError', actual_log[:error][:type]
|
363
363
|
end
|
364
|
+
|
365
|
+
it 'can log just an error as "error", if no message is given' do
|
366
|
+
e = StandardError.new('some error')
|
367
|
+
@logger.error(nil, e)
|
368
|
+
|
369
|
+
actual_log = read_json(@buffer)
|
370
|
+
|
371
|
+
assert_equal 'some error', actual_log[:message]
|
372
|
+
assert_equal 'StandardError', actual_log[:error][:type]
|
373
|
+
assert_equal 'some error', actual_log[:error][:message]
|
374
|
+
end
|
375
|
+
|
376
|
+
[:debug, :info, :warn].each do |level|
|
377
|
+
it "can log an error with type, error message etc.. as '#{level}'" do
|
378
|
+
error_message = "error to be logged as #{level}"
|
379
|
+
e = StandardError.new(error_message)
|
380
|
+
@logger.public_send(level, e)
|
381
|
+
|
382
|
+
actual_log = read_json(@buffer)
|
383
|
+
|
384
|
+
assert_equal error_message, actual_log[:message]
|
385
|
+
assert_equal 'StandardError', actual_log[:error][:type]
|
386
|
+
assert_equal error_message, actual_log[:error][:message]
|
387
|
+
end
|
388
|
+
end
|
364
389
|
end
|
365
390
|
|
366
391
|
describe 'text logging' do
|
@@ -420,6 +445,15 @@ describe Twiglet::Logger do
|
|
420
445
|
assert_equal 'a block log message', actual_log[:message]
|
421
446
|
end
|
422
447
|
end
|
448
|
+
|
449
|
+
it 'should ignore the given progname if a block is also given' do
|
450
|
+
block = proc { 'a block log message' }
|
451
|
+
@logger.info('my-program-name', &block)
|
452
|
+
actual_log = read_json(@buffer)
|
453
|
+
|
454
|
+
assert_equal 'info', actual_log[:log][:level]
|
455
|
+
assert_equal 'a block log message', actual_log[:message]
|
456
|
+
end
|
423
457
|
end
|
424
458
|
|
425
459
|
describe 'dotted keys' do
|
data/twiglet.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twiglet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simply Business
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-schema
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- ".github/workflows/codeql-analysis.yml"
|
93
93
|
- ".github/workflows/dobby-actions.yml"
|
94
94
|
- ".github/workflows/gem-publish.yml"
|
95
|
+
- ".github/workflows/project-board.yml"
|
95
96
|
- ".github/workflows/ruby.yml"
|
96
97
|
- ".github/workflows/version-forget-me-not.yml"
|
97
98
|
- ".gitignore"
|