legion-logging 0.1.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +53 -137
- data/.idea/.rakeTasks +7 -0
- data/.idea/legion-logging.iml +38 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vagrant.xml +7 -0
- data/.idea/workspace.xml +14 -0
- data/.rubocop.yml +4 -3
- data/Gemfile +0 -1
- data/bitbucket-pipelines.yml +14 -29
- data/legion-logging.gemspec +4 -5
- data/lib/legion/logging.rb +4 -0
- data/lib/legion/logging/builder.rb +27 -8
- data/lib/legion/logging/logger.rb +11 -7
- data/lib/legion/logging/methods.rb +39 -0
- data/lib/legion/logging/version.rb +1 -1
- data/sonar-project.properties +12 -0
- metadata +30 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ecd67d5e6c68af98e3b53869a576f4d9cfb4021498f66903bfd57b5ff533e1
|
4
|
+
data.tar.gz: 896e360f937631af59ea1cf4cba88be1baa8b6d23a432506c3c016db6c263f1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8d7e995ca4a2ed5f54636ebbe9fdea124f47caea4e0c43c5e65dcfc5f6716d770394cc94d033fbfacdb6d2cb3cc8d80319637485a62388362eb8468842c482f
|
7
|
+
data.tar.gz: 15f2613124940fbeee5868992c6ef7f53f3b10950d2bb835145309c4a82a8a67a92f3de1e23fdbb71a91e68c4f6ba67eab43ee98d549d4f9e1d3d3c214c5a8a3
|
data/.circleci/config.yml
CHANGED
@@ -1,167 +1,83 @@
|
|
1
|
-
version: 2
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.2.1
|
4
|
+
sonarcloud: sonarsource/sonarcloud@1.0.1
|
5
|
+
|
2
6
|
jobs:
|
3
7
|
"rubocop":
|
4
8
|
docker:
|
5
|
-
- image: circleci/ruby:2.
|
9
|
+
- image: circleci/ruby:2.7-node
|
6
10
|
steps:
|
7
11
|
- checkout
|
8
|
-
-
|
12
|
+
- ruby/load-cache
|
13
|
+
- ruby/install-deps
|
9
14
|
- run:
|
10
15
|
name: Run Rubocop
|
11
|
-
command: rubocop
|
12
|
-
-
|
13
|
-
|
14
|
-
"ruby-2.0":
|
15
|
-
docker:
|
16
|
-
- image: circleci/ruby:2.0
|
17
|
-
steps:
|
18
|
-
- checkout
|
19
|
-
- run:
|
20
|
-
name: Bundle Install
|
21
|
-
command: bundle install
|
22
|
-
- run:
|
23
|
-
name: Run RSpec
|
24
|
-
command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
|
25
|
-
when: always
|
26
|
-
- store_test_results:
|
27
|
-
path: test-results
|
28
|
-
"ruby-2.1":
|
29
|
-
docker:
|
30
|
-
- image: circleci/ruby:2.1
|
31
|
-
steps:
|
32
|
-
- checkout
|
33
|
-
- run:
|
34
|
-
name: Bundle Install
|
35
|
-
command: bundle install
|
36
|
-
- run:
|
37
|
-
name: Run RSpec
|
38
|
-
command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
|
39
|
-
when: always
|
40
|
-
- store_test_results:
|
41
|
-
path: test-results
|
42
|
-
"ruby-2.2":
|
43
|
-
docker:
|
44
|
-
- image: circleci/ruby:2.2
|
45
|
-
steps:
|
46
|
-
- checkout
|
47
|
-
- run:
|
48
|
-
name: Bundle Install
|
49
|
-
command: bundle install
|
50
|
-
- run:
|
51
|
-
name: Run RSpec
|
52
|
-
command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
|
53
|
-
when: always
|
54
|
-
- store_test_results:
|
55
|
-
path: test-results
|
56
|
-
|
57
|
-
"ruby-2.3":
|
58
|
-
docker:
|
59
|
-
- image: circleci/ruby:2.3
|
60
|
-
steps:
|
61
|
-
- checkout
|
62
|
-
- run:
|
63
|
-
name: Bundle Install
|
64
|
-
command: bundle install
|
65
|
-
- run:
|
66
|
-
name: Run RSpec
|
67
|
-
command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
|
68
|
-
when: always
|
69
|
-
- store_test_results:
|
70
|
-
path: test-results
|
71
|
-
|
72
|
-
"ruby-2.4":
|
16
|
+
command: bundle exec rubocop
|
17
|
+
- ruby/save-cache
|
18
|
+
"ruby-two-five":
|
73
19
|
docker:
|
74
|
-
- image: circleci/ruby:2.
|
20
|
+
- image: circleci/ruby:2.5
|
75
21
|
steps:
|
76
22
|
- checkout
|
77
|
-
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
path: test-results
|
86
|
-
"ruby-2.5":
|
23
|
+
- ruby/load-cache
|
24
|
+
- run:
|
25
|
+
name: update bundler
|
26
|
+
command: gem update bundler
|
27
|
+
- ruby/install-deps
|
28
|
+
- ruby/run-tests
|
29
|
+
- ruby/save-cache
|
30
|
+
"ruby-two-six":
|
87
31
|
docker:
|
88
|
-
- image: circleci/ruby:2.
|
32
|
+
- image: circleci/ruby:2.6
|
89
33
|
steps:
|
90
34
|
- checkout
|
91
|
-
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
path: test-results
|
100
|
-
"ruby-2.6":
|
35
|
+
- ruby/load-cache
|
36
|
+
- run:
|
37
|
+
name: update bundler
|
38
|
+
command: gem update bundler
|
39
|
+
- ruby/install-deps
|
40
|
+
- ruby/run-tests
|
41
|
+
- ruby/save-cache
|
42
|
+
"ruby-two-seven":
|
101
43
|
docker:
|
102
|
-
- image: circleci/ruby:2.
|
44
|
+
- image: circleci/ruby:2.7
|
45
|
+
- image: memcached:1.5-alpine
|
103
46
|
steps:
|
104
47
|
- checkout
|
105
|
-
-
|
106
|
-
|
107
|
-
|
108
|
-
-
|
109
|
-
|
110
|
-
command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
|
111
|
-
when: always
|
112
|
-
- store_test_results:
|
113
|
-
path: test-results
|
114
|
-
"jruby-9.2":
|
48
|
+
- ruby/load-cache
|
49
|
+
- ruby/install-deps
|
50
|
+
- ruby/run-tests
|
51
|
+
- ruby/save-cache
|
52
|
+
"sonarcloud":
|
115
53
|
docker:
|
116
|
-
- image: circleci/
|
54
|
+
- image: circleci/ruby:2.7
|
117
55
|
steps:
|
118
56
|
- checkout
|
57
|
+
- ruby/load-cache
|
58
|
+
- ruby/install-deps
|
59
|
+
- ruby/run-tests
|
119
60
|
- run:
|
120
|
-
name:
|
121
|
-
command: bundle
|
122
|
-
-
|
123
|
-
|
124
|
-
command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
|
125
|
-
when: always
|
126
|
-
- store_test_results:
|
127
|
-
path: test-results
|
61
|
+
name: Run Rubocop
|
62
|
+
command: bundle exec rubocop --format=json --out=rubocop-result.json
|
63
|
+
- sonarcloud/scan
|
64
|
+
- ruby/save-cache
|
128
65
|
|
129
66
|
workflows:
|
130
67
|
version: 2
|
131
|
-
|
68
|
+
rubocop-rspec:
|
132
69
|
jobs:
|
133
70
|
- rubocop
|
134
|
-
|
135
|
-
# requires:
|
136
|
-
# - ruby-2.4
|
137
|
-
# filters:
|
138
|
-
# branches:
|
139
|
-
# only: /\bdevelop\b|\bmaster\b/
|
140
|
-
- ruby-2.3:
|
141
|
-
requires:
|
142
|
-
- ruby-2.4
|
143
|
-
filters:
|
144
|
-
branches:
|
145
|
-
only: /\bdevelop\b|\bmaster\b/
|
146
|
-
- ruby-2.4:
|
71
|
+
- ruby-two-five:
|
147
72
|
requires:
|
148
73
|
- rubocop
|
149
|
-
- ruby-
|
74
|
+
- ruby-two-six:
|
150
75
|
requires:
|
151
|
-
- ruby-
|
152
|
-
|
153
|
-
branches:
|
154
|
-
only: /\bdevelop\b|\bmaster\b/
|
155
|
-
- ruby-2.6:
|
76
|
+
- ruby-two-five
|
77
|
+
- ruby-two-seven:
|
156
78
|
requires:
|
157
|
-
- ruby-
|
158
|
-
|
159
|
-
branches:
|
160
|
-
only: /\bdevelop\b|\bmaster\b/
|
161
|
-
- jruby-9.2:
|
79
|
+
- ruby-two-five
|
80
|
+
- sonarcloud:
|
162
81
|
requires:
|
163
|
-
|
164
|
-
- ruby-
|
165
|
-
- ruby-2.4
|
166
|
-
- ruby-2.5
|
167
|
-
- ruby-2.6
|
82
|
+
- ruby-two-seven
|
83
|
+
- ruby-two-six
|
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build legion-logging-0.1.3.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install legion-logging-0.1.3.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install legion-logging-0.1.3.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.3 and build and push legion-logging-0.1.3.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$" />
|
8
|
+
<orderEntry type="jdk" jdkName="RVM: ruby-2.7.0" jdkType="RUBY_SDK" />
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.7.0) [gem]" level="application" />
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="chef (v16.1.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="codecov (v0.2.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="colorize (v0.8.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, RVM: ruby-2.7.0) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v2.3.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v2.7.1.4, RVM: ruby-2.7.0) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v1.7.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.7.0) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.3, RVM: ruby-2.7.0) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec_junit_formatter (v0.4.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.88.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v0.2.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.7.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.17.1, RVM: ruby-2.7.0) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.10.2, RVM: ruby-2.7.0) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.7.0, RVM: ruby-2.7.0) [gem]" level="application" />
|
37
|
+
</component>
|
38
|
+
</module>
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="JavaScriptSettings">
|
4
|
+
<option name="languageLevel" value="ES6" />
|
5
|
+
</component>
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.6.3" project-jdk-type="RUBY_SDK" />
|
7
|
+
</project>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/legion-logging.iml" filepath="$PROJECT_DIR$/.idea/legion-logging.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/vagrant.xml
ADDED
data/.idea/workspace.xml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="CoverageOptionsProvider">
|
4
|
+
<option name="myAddOrReplace" value="0" />
|
5
|
+
</component>
|
6
|
+
<component name="Git.Settings">
|
7
|
+
<option name="PUSH_AUTO_UPDATE" value="true" />
|
8
|
+
<option name="ROOT_SYNC" value="DONT_SYNC" />
|
9
|
+
</component>
|
10
|
+
<component name="ProjectId" id="1Yl3Ni6NlUlB0HwEdc23TcNXMXO" />
|
11
|
+
<component name="PropertiesComponent">
|
12
|
+
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.vagrant" />
|
13
|
+
</component>
|
14
|
+
</project>
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
Layout/LineLength:
|
2
2
|
Max: 120
|
3
3
|
Metrics/MethodLength:
|
4
4
|
Max: 30
|
5
5
|
Metrics/ClassLength:
|
6
6
|
Max: 1500
|
7
7
|
Metrics/BlockLength:
|
8
|
-
Max:
|
8
|
+
Max: 75
|
9
9
|
Layout/SpaceAroundEqualsInParameterDefault:
|
10
10
|
EnforcedStyle: space
|
11
11
|
Style/SymbolArray:
|
@@ -16,6 +16,7 @@ Layout/HashAlignment:
|
|
16
16
|
Style/Documentation:
|
17
17
|
Enabled: false
|
18
18
|
AllCops:
|
19
|
-
TargetRubyVersion: 2.
|
19
|
+
TargetRubyVersion: 2.5
|
20
|
+
NewCops: enable
|
20
21
|
Style/FrozenStringLiteralComment:
|
21
22
|
Enabled: false
|
data/Gemfile
CHANGED
data/bitbucket-pipelines.yml
CHANGED
@@ -1,33 +1,18 @@
|
|
1
|
-
image: ruby:2.
|
1
|
+
image: ruby:2.7.0
|
2
2
|
|
3
3
|
pipelines:
|
4
4
|
branches:
|
5
5
|
master:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
- bundle install
|
20
|
-
- gem build legion-logging.gemspec
|
21
|
-
- gem inabox legion-logging*.gem -g https://gems.whonodes.org/ -o
|
22
|
-
default:
|
23
|
-
- step:
|
24
|
-
caches:
|
25
|
-
- bundler
|
26
|
-
script:
|
27
|
-
- gem install bundle rubocop
|
28
|
-
- bundle install
|
29
|
-
- rubocop
|
30
|
-
- rake
|
31
|
-
definitions:
|
32
|
-
caches:
|
33
|
-
bundler: vendor/bundle
|
6
|
+
- step:
|
7
|
+
name: Push to RubyGems
|
8
|
+
deployment: RubyGems
|
9
|
+
script:
|
10
|
+
- gem install bundler gem-release rake rspec
|
11
|
+
- bundle install
|
12
|
+
- rake build
|
13
|
+
- mkdir .gem
|
14
|
+
- (umask 077 ; echo $gem_creds | base64 --decode > .gem/credentials)
|
15
|
+
- gem release
|
16
|
+
- gem tag --push
|
17
|
+
artifacts:
|
18
|
+
- pkg/**
|
data/legion-logging.gemspec
CHANGED
@@ -22,18 +22,17 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
23
|
f.match(%r{^(test|spec|features)/})
|
24
24
|
end
|
25
|
-
spec.bindir = 'exe'
|
26
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
26
|
spec.require_paths = ['lib']
|
28
27
|
|
29
28
|
spec.add_development_dependency 'bundler'
|
30
29
|
spec.add_development_dependency 'codecov'
|
31
|
-
spec.add_development_dependency 'rake'
|
32
|
-
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'rake'
|
31
|
+
spec.add_development_dependency 'rspec'
|
33
32
|
spec.add_development_dependency 'rspec_junit_formatter'
|
34
33
|
spec.add_development_dependency 'rubocop'
|
35
|
-
spec.add_development_dependency '
|
34
|
+
spec.add_development_dependency 'rubocop-performance'
|
35
|
+
spec.add_development_dependency 'simplecov', '< 0.18.0'
|
36
36
|
|
37
|
-
spec.add_dependency 'logger', '~> 1.3'
|
38
37
|
spec.add_dependency 'rainbow', '~> 3'
|
39
38
|
end
|
data/lib/legion/logging.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
module Legion
|
2
2
|
module Logging
|
3
3
|
module Builder
|
4
|
-
def log_format(
|
4
|
+
def log_format(options = {}, log = @log) # rubocop:disable Metrics/AbcSize
|
5
5
|
log.formatter = proc do |severity, datetime, _progname, msg|
|
6
|
-
"[
|
6
|
+
options[:lex_name] = options.key?(:lex) ? "[lex-#{options[:lex]}]" : nil
|
7
|
+
unless options[:lex_name].nil?
|
8
|
+
data = caller_locations[4].to_s.split('/').last(2)
|
9
|
+
runner_trace = {
|
10
|
+
type: data[0],
|
11
|
+
file: data[1].split('.')[0],
|
12
|
+
function: data[1].split('`')[1].delete_suffix('\''),
|
13
|
+
line_number: data[1].split(':')[1]
|
14
|
+
}
|
15
|
+
end
|
16
|
+
string = "[#{datetime}][#{::Process.pid}]"
|
17
|
+
string.concat(options[:lex_name]) unless options[:lex_name].nil?
|
18
|
+
if runner_trace.is_a?(Hash) && (options[:extended] || severity == 'debug')
|
19
|
+
string.concat("[#{runner_trace[:type]}:#{runner_trace[:file]}:#{runner_trace[:line_number]}]")
|
20
|
+
end
|
21
|
+
string.concat(" #{severity} #{msg}\n")
|
22
|
+
string
|
7
23
|
end
|
8
24
|
end
|
9
25
|
|
@@ -12,16 +28,19 @@ module Legion
|
|
12
28
|
@log = ::Logger.new(options[:log_file]) unless options[:log_file].nil?
|
13
29
|
end
|
14
30
|
|
15
|
-
def log_level(level = '
|
16
|
-
|
31
|
+
def log_level(level = 'info', log = @log)
|
32
|
+
case level
|
33
|
+
when 'trace'
|
34
|
+
log.level = ::Logger::INFO
|
35
|
+
when 'debug'
|
17
36
|
log.level = ::Logger::DEBUG
|
18
|
-
|
37
|
+
when 'info'
|
19
38
|
log.level = ::Logger::INFO
|
20
|
-
|
39
|
+
when 'warn'
|
21
40
|
log.level = ::Logger::WARN
|
22
|
-
|
41
|
+
when 'error'
|
23
42
|
log.level = ::Logger::ERROR
|
24
|
-
|
43
|
+
when 'fatal'
|
25
44
|
log.level = ::Logger::FATAL
|
26
45
|
end
|
27
46
|
@log = log
|
@@ -4,16 +4,20 @@ require 'legion/logging/builder'
|
|
4
4
|
module Legion
|
5
5
|
module Logging
|
6
6
|
class Logger
|
7
|
-
|
7
|
+
attr_accessor :log, :color, :level, :lex, :log_file, :trace_enabled, :extended
|
8
|
+
|
8
9
|
include Legion::Logging::Methods
|
9
10
|
include Legion::Logging::Builder
|
10
11
|
|
11
|
-
def initialize(
|
12
|
-
output(
|
13
|
-
log_level(
|
14
|
-
log_format(
|
15
|
-
@color =
|
16
|
-
@color = true if
|
12
|
+
def initialize(level: 'info', log_file: nil, lex: nil, trace: false, extended: false, trace_size: 4, **opts) # rubocop:disable Metrics/ParameterLists
|
13
|
+
output(logfile: log_file)
|
14
|
+
log_level(level)
|
15
|
+
log_format(lex: lex, extended: extended, **opts)
|
16
|
+
@color = opts[:color]
|
17
|
+
@color = true if opts[:color].nil? && log_file.nil?
|
18
|
+
@trace_enabled = trace
|
19
|
+
@trace_size = trace_size
|
20
|
+
@extended = extended
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -1,31 +1,55 @@
|
|
1
1
|
module Legion
|
2
2
|
module Logging
|
3
3
|
module Methods
|
4
|
+
def trace(raw_message = nil, log = @log, size: @trace_size, log_caller: true) # rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize
|
5
|
+
return unless @trace_enabled
|
6
|
+
|
7
|
+
raw_message = yield if raw_message.nil? && block_given?
|
8
|
+
message = Rainbow('Tracing: ').cyan
|
9
|
+
message.concat Rainbow(raw_message + ' ').cyan
|
10
|
+
if log_caller && size.nil?
|
11
|
+
message.concat Rainbow(caller_locations).cyan.underline
|
12
|
+
elsif log_caller
|
13
|
+
message.concat Rainbow(caller_locations[0..size]).cyan.underline
|
14
|
+
end
|
15
|
+
log.unknown(message)
|
16
|
+
end
|
17
|
+
|
4
18
|
def debug(message = nil, log = @log)
|
19
|
+
return unless log.level < 1
|
20
|
+
|
5
21
|
message = yield if message.nil? && block_given?
|
6
22
|
message = Rainbow(message).blue if @color
|
7
23
|
log.debug(message)
|
8
24
|
end
|
9
25
|
|
10
26
|
def info(message = nil, log = @log)
|
27
|
+
return unless log.level < 2
|
28
|
+
|
11
29
|
message = yield if message.nil? && block_given?
|
12
30
|
message = Rainbow(message).green if @color
|
13
31
|
log.info(message)
|
14
32
|
end
|
15
33
|
|
16
34
|
def warn(message = nil, log = @log)
|
35
|
+
return unless log.level < 3
|
36
|
+
|
17
37
|
message = yield if message.nil? && block_given?
|
18
38
|
message = Rainbow(message).yellow if @color
|
19
39
|
log.warn(message)
|
20
40
|
end
|
21
41
|
|
22
42
|
def error(message = nil, log = @log)
|
43
|
+
return unless log.level < 4
|
44
|
+
|
23
45
|
message = yield if message.nil? && block_given?
|
24
46
|
message = Rainbow(message).red if @color
|
25
47
|
log.error(message)
|
26
48
|
end
|
27
49
|
|
28
50
|
def fatal(message = nil, log = @log)
|
51
|
+
return unless log.level < 5
|
52
|
+
|
29
53
|
message = yield if message.nil? && block_given?
|
30
54
|
message = Rainbow(message).darkred if @color
|
31
55
|
log.fatal(message)
|
@@ -36,6 +60,21 @@ module Legion
|
|
36
60
|
message = Rainbow(message).purple if @color
|
37
61
|
log.unknown(message)
|
38
62
|
end
|
63
|
+
|
64
|
+
def runner_exception(exc, **opts)
|
65
|
+
Legion::Logging.error exc.message
|
66
|
+
Legion::Logging.error exc.backtrace
|
67
|
+
Legion::Logging.error opts
|
68
|
+
{ success: false, message: exc.message, backtrace: exc.backtrace }.merge(opts)
|
69
|
+
end
|
70
|
+
|
71
|
+
def thread(kvl: false, **_opts)
|
72
|
+
if kvl
|
73
|
+
"thread=#{Thread.current.object_id}"
|
74
|
+
else
|
75
|
+
Thread.current.object_id.to_s
|
76
|
+
end
|
77
|
+
end
|
39
78
|
end
|
40
79
|
end
|
41
80
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
sonar.projectKey=legion-io_legion-logging
|
2
|
+
sonar.organization=legion-io
|
3
|
+
sonar.projectName=Legion::Logging
|
4
|
+
sonar.sources=.
|
5
|
+
sonar.exclusions=vendor/**
|
6
|
+
sonar.coverage.exclusions=spec/**
|
7
|
+
sonar.ruby.coverage.reportPath=coverage/.resultset.json
|
8
|
+
sonar.ruby.file.suffixes=rb,ruby
|
9
|
+
sonar.ruby.coverage.framework=RSpec
|
10
|
+
sonar.ruby.rubocopConfig=.rubocop.yml
|
11
|
+
sonar.ruby.rubocop.reportPath=rubocop-result.json
|
12
|
+
sonar.ruby.rubocop.filePath=.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legion-logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esity
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,30 +42,30 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec_junit_formatter
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rubocop-performance
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,19 +109,19 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "<"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
type: :
|
117
|
+
version: 0.18.0
|
118
|
+
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "<"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.18.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rainbow
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,9 +145,16 @@ extra_rdoc_files: []
|
|
145
145
|
files:
|
146
146
|
- ".circleci/config.yml"
|
147
147
|
- ".gitignore"
|
148
|
+
- ".idea/.rakeTasks"
|
149
|
+
- ".idea/legion-logging.iml"
|
150
|
+
- ".idea/misc.xml"
|
151
|
+
- ".idea/modules.xml"
|
152
|
+
- ".idea/vagrant.xml"
|
153
|
+
- ".idea/workspace.xml"
|
148
154
|
- ".rubocop.yml"
|
149
155
|
- CHANGELOG.md
|
150
156
|
- Gemfile
|
157
|
+
- Gemfile.lock
|
151
158
|
- README.md
|
152
159
|
- Rakefile
|
153
160
|
- bitbucket-pipelines.yml
|
@@ -157,6 +164,7 @@ files:
|
|
157
164
|
- lib/legion/logging/logger.rb
|
158
165
|
- lib/legion/logging/methods.rb
|
159
166
|
- lib/legion/logging/version.rb
|
167
|
+
- sonar-project.properties
|
160
168
|
homepage: https://bitbucket.org/legion-io/legion-logging
|
161
169
|
licenses: []
|
162
170
|
metadata:
|
@@ -166,7 +174,7 @@ metadata:
|
|
166
174
|
homepage_uri: https://bitbucket.org/legion-io/legion-logging
|
167
175
|
source_code_uri: https://bitbucket.org/legion-io/legion-logging
|
168
176
|
wiki_uri: https://bitbucket.org/legion-io/legion-logging/wiki/Home
|
169
|
-
post_install_message:
|
177
|
+
post_install_message:
|
170
178
|
rdoc_options: []
|
171
179
|
require_paths:
|
172
180
|
- lib
|
@@ -181,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
189
|
- !ruby/object:Gem::Version
|
182
190
|
version: '0'
|
183
191
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
185
|
-
signing_key:
|
192
|
+
rubygems_version: 3.1.2
|
193
|
+
signing_key:
|
186
194
|
specification_version: 4
|
187
195
|
summary: The Legion::Logging class
|
188
196
|
test_files: []
|