legion-logging 1.1.0
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 +7 -0
- data/.circleci/config.yml +83 -0
- data/.gitignore +15 -0
- 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 +22 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +3 -0
- data/README.md +42 -0
- data/Rakefile +6 -0
- data/bitbucket-pipelines.yml +18 -0
- data/legion-logging.gemspec +38 -0
- data/lib/legion/logging.rb +29 -0
- data/lib/legion/logging/builder.rb +50 -0
- data/lib/legion/logging/logger.rb +24 -0
- data/lib/legion/logging/methods.rb +80 -0
- data/lib/legion/logging/version.rb +5 -0
- data/sonar-project.properties +12 -0
- metadata +196 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e9ecd67d5e6c68af98e3b53869a576f4d9cfb4021498f66903bfd57b5ff533e1
|
|
4
|
+
data.tar.gz: 896e360f937631af59ea1cf4cba88be1baa8b6d23a432506c3c016db6c263f1f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d8d7e995ca4a2ed5f54636ebbe9fdea124f47caea4e0c43c5e65dcfc5f6716d770394cc94d033fbfacdb6d2cb3cc8d80319637485a62388362eb8468842c482f
|
|
7
|
+
data.tar.gz: 15f2613124940fbeee5868992c6ef7f53f3b10950d2bb835145309c4a82a8a67a92f3de1e23fdbb71a91e68c4f6ba67eab43ee98d549d4f9e1d3d3c214c5a8a3
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
orbs:
|
|
3
|
+
ruby: circleci/ruby@0.2.1
|
|
4
|
+
sonarcloud: sonarsource/sonarcloud@1.0.1
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
"rubocop":
|
|
8
|
+
docker:
|
|
9
|
+
- image: circleci/ruby:2.7-node
|
|
10
|
+
steps:
|
|
11
|
+
- checkout
|
|
12
|
+
- ruby/load-cache
|
|
13
|
+
- ruby/install-deps
|
|
14
|
+
- run:
|
|
15
|
+
name: Run Rubocop
|
|
16
|
+
command: bundle exec rubocop
|
|
17
|
+
- ruby/save-cache
|
|
18
|
+
"ruby-two-five":
|
|
19
|
+
docker:
|
|
20
|
+
- image: circleci/ruby:2.5
|
|
21
|
+
steps:
|
|
22
|
+
- checkout
|
|
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":
|
|
31
|
+
docker:
|
|
32
|
+
- image: circleci/ruby:2.6
|
|
33
|
+
steps:
|
|
34
|
+
- checkout
|
|
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":
|
|
43
|
+
docker:
|
|
44
|
+
- image: circleci/ruby:2.7
|
|
45
|
+
- image: memcached:1.5-alpine
|
|
46
|
+
steps:
|
|
47
|
+
- checkout
|
|
48
|
+
- ruby/load-cache
|
|
49
|
+
- ruby/install-deps
|
|
50
|
+
- ruby/run-tests
|
|
51
|
+
- ruby/save-cache
|
|
52
|
+
"sonarcloud":
|
|
53
|
+
docker:
|
|
54
|
+
- image: circleci/ruby:2.7
|
|
55
|
+
steps:
|
|
56
|
+
- checkout
|
|
57
|
+
- ruby/load-cache
|
|
58
|
+
- ruby/install-deps
|
|
59
|
+
- ruby/run-tests
|
|
60
|
+
- run:
|
|
61
|
+
name: Run Rubocop
|
|
62
|
+
command: bundle exec rubocop --format=json --out=rubocop-result.json
|
|
63
|
+
- sonarcloud/scan
|
|
64
|
+
- ruby/save-cache
|
|
65
|
+
|
|
66
|
+
workflows:
|
|
67
|
+
version: 2
|
|
68
|
+
rubocop-rspec:
|
|
69
|
+
jobs:
|
|
70
|
+
- rubocop
|
|
71
|
+
- ruby-two-five:
|
|
72
|
+
requires:
|
|
73
|
+
- rubocop
|
|
74
|
+
- ruby-two-six:
|
|
75
|
+
requires:
|
|
76
|
+
- ruby-two-five
|
|
77
|
+
- ruby-two-seven:
|
|
78
|
+
requires:
|
|
79
|
+
- ruby-two-five
|
|
80
|
+
- sonarcloud:
|
|
81
|
+
requires:
|
|
82
|
+
- ruby-two-seven
|
|
83
|
+
- ruby-two-six
|
data/.gitignore
ADDED
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
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Layout/LineLength:
|
|
2
|
+
Max: 120
|
|
3
|
+
Metrics/MethodLength:
|
|
4
|
+
Max: 30
|
|
5
|
+
Metrics/ClassLength:
|
|
6
|
+
Max: 1500
|
|
7
|
+
Metrics/BlockLength:
|
|
8
|
+
Max: 75
|
|
9
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
+
EnforcedStyle: space
|
|
11
|
+
Style/SymbolArray:
|
|
12
|
+
Enabled: true
|
|
13
|
+
Layout/HashAlignment:
|
|
14
|
+
EnforcedHashRocketStyle: table
|
|
15
|
+
EnforcedColonStyle: table
|
|
16
|
+
Style/Documentation:
|
|
17
|
+
Enabled: false
|
|
18
|
+
AllCops:
|
|
19
|
+
TargetRubyVersion: 2.5
|
|
20
|
+
NewCops: enable
|
|
21
|
+
Style/FrozenStringLiteralComment:
|
|
22
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Legion::Logging
|
|
2
|
+
|
|
3
|
+
Legion::Logging is part of the Legion Framework
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'legion-logging'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install legion-logging
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
This library is utilized by Legion to log messages
|
|
25
|
+
|
|
26
|
+
## Gem
|
|
27
|
+
|
|
28
|
+
This gem can be viewed and download from [RubyGems - Legion-Logging](https://rubygems.org/gems/legion-logging)
|
|
29
|
+
|
|
30
|
+
## Development
|
|
31
|
+
|
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
33
|
+
|
|
34
|
+
To install this gem onto your local machine, run `bundle exec install`.
|
|
35
|
+
|
|
36
|
+
## Contributing
|
|
37
|
+
|
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://bitbucket.org/legion-io/legion-logging/issues This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
image: ruby:2.7.0
|
|
2
|
+
|
|
3
|
+
pipelines:
|
|
4
|
+
branches:
|
|
5
|
+
master:
|
|
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/**
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'legion/logging/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'legion-logging'
|
|
7
|
+
spec.version = Legion::Logging::VERSION
|
|
8
|
+
spec.authors = ['Esity']
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'The Legion::Logging class'
|
|
12
|
+
spec.description = 'Legion Logging is used for logging things'
|
|
13
|
+
spec.homepage = 'https://bitbucket.org/legion-io/legion-logging'
|
|
14
|
+
|
|
15
|
+
spec.metadata['bug_tracker_uri'] = 'https://bitbucket.org/legion-io/legion-logging/issues?status=new&status=open'
|
|
16
|
+
spec.metadata['changelog_uri'] = 'https://bitbucket.org/legion-io/legion-logging/src/CHANGELOG.md'
|
|
17
|
+
spec.metadata['documentation_uri'] = 'https://bitbucket.org/legion-io/legion-logging'
|
|
18
|
+
spec.metadata['homepage_uri'] = 'https://bitbucket.org/legion-io/legion-logging'
|
|
19
|
+
spec.metadata['source_code_uri'] = 'https://bitbucket.org/legion-io/legion-logging'
|
|
20
|
+
spec.metadata['wiki_uri'] = 'https://bitbucket.org/legion-io/legion-logging/wiki/Home'
|
|
21
|
+
|
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
23
|
+
f.match(%r{^(test|spec|features)/})
|
|
24
|
+
end
|
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
26
|
+
spec.require_paths = ['lib']
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency 'bundler'
|
|
29
|
+
spec.add_development_dependency 'codecov'
|
|
30
|
+
spec.add_development_dependency 'rake'
|
|
31
|
+
spec.add_development_dependency 'rspec'
|
|
32
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
|
33
|
+
spec.add_development_dependency 'rubocop'
|
|
34
|
+
spec.add_development_dependency 'rubocop-performance'
|
|
35
|
+
spec.add_development_dependency 'simplecov', '< 0.18.0'
|
|
36
|
+
|
|
37
|
+
spec.add_dependency 'rainbow', '~> 3'
|
|
38
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'legion/logging/version'
|
|
2
|
+
require 'legion/logging/logger'
|
|
3
|
+
require 'legion/logging/methods'
|
|
4
|
+
require 'legion/logging/builder'
|
|
5
|
+
|
|
6
|
+
require 'logger'
|
|
7
|
+
require 'rainbow'
|
|
8
|
+
|
|
9
|
+
module Legion
|
|
10
|
+
module Logging
|
|
11
|
+
class << self
|
|
12
|
+
include Legion::Logging::Methods
|
|
13
|
+
include Legion::Logging::Builder
|
|
14
|
+
attr_reader :log, :color
|
|
15
|
+
|
|
16
|
+
def level
|
|
17
|
+
@log.level
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def setup(options = {})
|
|
21
|
+
output(options)
|
|
22
|
+
log_level(options[:level])
|
|
23
|
+
log_format(options)
|
|
24
|
+
@color = options[:color]
|
|
25
|
+
@color = true if options[:color].nil? && options[:log_file].nil?
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Legion
|
|
2
|
+
module Logging
|
|
3
|
+
module Builder
|
|
4
|
+
def log_format(options = {}, log = @log) # rubocop:disable Metrics/AbcSize
|
|
5
|
+
log.formatter = proc do |severity, datetime, _progname, msg|
|
|
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
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def output(options)
|
|
27
|
+
@log = ::Logger.new($stdout) if options[:log_file].nil?
|
|
28
|
+
@log = ::Logger.new(options[:log_file]) unless options[:log_file].nil?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def log_level(level = 'info', log = @log)
|
|
32
|
+
case level
|
|
33
|
+
when 'trace'
|
|
34
|
+
log.level = ::Logger::INFO
|
|
35
|
+
when 'debug'
|
|
36
|
+
log.level = ::Logger::DEBUG
|
|
37
|
+
when 'info'
|
|
38
|
+
log.level = ::Logger::INFO
|
|
39
|
+
when 'warn'
|
|
40
|
+
log.level = ::Logger::WARN
|
|
41
|
+
when 'error'
|
|
42
|
+
log.level = ::Logger::ERROR
|
|
43
|
+
when 'fatal'
|
|
44
|
+
log.level = ::Logger::FATAL
|
|
45
|
+
end
|
|
46
|
+
@log = log
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'legion/logging/methods'
|
|
2
|
+
require 'legion/logging/builder'
|
|
3
|
+
|
|
4
|
+
module Legion
|
|
5
|
+
module Logging
|
|
6
|
+
class Logger
|
|
7
|
+
attr_accessor :log, :color, :level, :lex, :log_file, :trace_enabled, :extended
|
|
8
|
+
|
|
9
|
+
include Legion::Logging::Methods
|
|
10
|
+
include Legion::Logging::Builder
|
|
11
|
+
|
|
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
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Legion
|
|
2
|
+
module Logging
|
|
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
|
+
|
|
18
|
+
def debug(message = nil, log = @log)
|
|
19
|
+
return unless log.level < 1
|
|
20
|
+
|
|
21
|
+
message = yield if message.nil? && block_given?
|
|
22
|
+
message = Rainbow(message).blue if @color
|
|
23
|
+
log.debug(message)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def info(message = nil, log = @log)
|
|
27
|
+
return unless log.level < 2
|
|
28
|
+
|
|
29
|
+
message = yield if message.nil? && block_given?
|
|
30
|
+
message = Rainbow(message).green if @color
|
|
31
|
+
log.info(message)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def warn(message = nil, log = @log)
|
|
35
|
+
return unless log.level < 3
|
|
36
|
+
|
|
37
|
+
message = yield if message.nil? && block_given?
|
|
38
|
+
message = Rainbow(message).yellow if @color
|
|
39
|
+
log.warn(message)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def error(message = nil, log = @log)
|
|
43
|
+
return unless log.level < 4
|
|
44
|
+
|
|
45
|
+
message = yield if message.nil? && block_given?
|
|
46
|
+
message = Rainbow(message).red if @color
|
|
47
|
+
log.error(message)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def fatal(message = nil, log = @log)
|
|
51
|
+
return unless log.level < 5
|
|
52
|
+
|
|
53
|
+
message = yield if message.nil? && block_given?
|
|
54
|
+
message = Rainbow(message).darkred if @color
|
|
55
|
+
log.fatal(message)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def unknown(message = nil, log = @log)
|
|
59
|
+
message = yield if message.nil? && block_given?
|
|
60
|
+
message = Rainbow(message).purple if @color
|
|
61
|
+
log.unknown(message)
|
|
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
|
|
78
|
+
end
|
|
79
|
+
end
|
|
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
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: legion-logging
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Esity
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: codecov
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec_junit_formatter
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rubocop-performance
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: simplecov
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "<"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.18.0
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "<"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.18.0
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: rainbow
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '3'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '3'
|
|
139
|
+
description: Legion Logging is used for logging things
|
|
140
|
+
email:
|
|
141
|
+
- matthewdiverson@gmail.com
|
|
142
|
+
executables: []
|
|
143
|
+
extensions: []
|
|
144
|
+
extra_rdoc_files: []
|
|
145
|
+
files:
|
|
146
|
+
- ".circleci/config.yml"
|
|
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"
|
|
154
|
+
- ".rubocop.yml"
|
|
155
|
+
- CHANGELOG.md
|
|
156
|
+
- Gemfile
|
|
157
|
+
- Gemfile.lock
|
|
158
|
+
- README.md
|
|
159
|
+
- Rakefile
|
|
160
|
+
- bitbucket-pipelines.yml
|
|
161
|
+
- legion-logging.gemspec
|
|
162
|
+
- lib/legion/logging.rb
|
|
163
|
+
- lib/legion/logging/builder.rb
|
|
164
|
+
- lib/legion/logging/logger.rb
|
|
165
|
+
- lib/legion/logging/methods.rb
|
|
166
|
+
- lib/legion/logging/version.rb
|
|
167
|
+
- sonar-project.properties
|
|
168
|
+
homepage: https://bitbucket.org/legion-io/legion-logging
|
|
169
|
+
licenses: []
|
|
170
|
+
metadata:
|
|
171
|
+
bug_tracker_uri: https://bitbucket.org/legion-io/legion-logging/issues?status=new&status=open
|
|
172
|
+
changelog_uri: https://bitbucket.org/legion-io/legion-logging/src/CHANGELOG.md
|
|
173
|
+
documentation_uri: https://bitbucket.org/legion-io/legion-logging
|
|
174
|
+
homepage_uri: https://bitbucket.org/legion-io/legion-logging
|
|
175
|
+
source_code_uri: https://bitbucket.org/legion-io/legion-logging
|
|
176
|
+
wiki_uri: https://bitbucket.org/legion-io/legion-logging/wiki/Home
|
|
177
|
+
post_install_message:
|
|
178
|
+
rdoc_options: []
|
|
179
|
+
require_paths:
|
|
180
|
+
- lib
|
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
|
+
requirements:
|
|
183
|
+
- - ">="
|
|
184
|
+
- !ruby/object:Gem::Version
|
|
185
|
+
version: '0'
|
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
|
+
requirements:
|
|
188
|
+
- - ">="
|
|
189
|
+
- !ruby/object:Gem::Version
|
|
190
|
+
version: '0'
|
|
191
|
+
requirements: []
|
|
192
|
+
rubygems_version: 3.1.2
|
|
193
|
+
signing_key:
|
|
194
|
+
specification_version: 4
|
|
195
|
+
summary: The Legion::Logging class
|
|
196
|
+
test_files: []
|