loglevel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +42 -0
- data/.hound.yml +4 -0
- data/.rspec +2 -0
- data/.rubocop.yml +49 -0
- data/.travis.yml +12 -0
- data/CODE_OF_CONDUCT.md +15 -0
- data/Gemfile +22 -0
- data/Guardfile +18 -0
- data/LICENSE +21 -0
- data/README.md +102 -0
- data/Rakefile +9 -0
- data/circle.yml +15 -0
- data/lib/loglevel/active_record.rb +23 -0
- data/lib/loglevel/classes.rb +29 -0
- data/lib/loglevel/help.rb +28 -0
- data/lib/loglevel/http_logger.rb +34 -0
- data/lib/loglevel/version.rb +5 -0
- data/lib/loglevel.rb +90 -0
- data/loglevel.gemspec +23 -0
- data/script/console +2 -0
- data/spec/loglevel/active_record_spec.rb +44 -0
- data/spec/loglevel/classes_spec.rb +44 -0
- data/spec/loglevel/help_spec.rb +27 -0
- data/spec/loglevel/http_logger_spec.rb +44 -0
- data/spec/loglevel_spec.rb +182 -0
- data/spec/spec_helper.rb +110 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64a78cf664473d8733fa5f9db3fda314e247028f
|
4
|
+
data.tar.gz: cf21175c9ab6a78b2122095bcdd00bb99206eef8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e46a36b63301ef0415617aa6ab235bc07b949a23e3fbfaa8f96a3963c403ec422b28e83ff579d77ddf33ccd48c8d138579287eb18b7ec26197f85a9e125fa96
|
7
|
+
data.tar.gz: af4cc0da3a99d0d617b77b64b85966146dec2833fdfd3660639277cc8f032db0c0ed75b1d26db751910bfbd6e7bfb7a5017ad0e0f54859d6dec7f08060138360
|
data/.gitignore
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
.ruby-gemset
|
2
|
+
.ruby-version
|
3
|
+
Gemfile.lock
|
4
|
+
|
5
|
+
*.rbc
|
6
|
+
capybara-*.html
|
7
|
+
/log
|
8
|
+
/tmp
|
9
|
+
/db/*.sqlite3
|
10
|
+
/db/*.sqlite3-journal
|
11
|
+
/public/system
|
12
|
+
/coverage/
|
13
|
+
/spec/tmp
|
14
|
+
**.orig
|
15
|
+
rerun.txt
|
16
|
+
pickle-email-*.html
|
17
|
+
|
18
|
+
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
19
|
+
config/initializers/secret_token.rb
|
20
|
+
config/secrets.yml
|
21
|
+
|
22
|
+
# dotenv
|
23
|
+
# TODO Comment out this rule if environment variables can be committed
|
24
|
+
.env
|
25
|
+
|
26
|
+
## Environment normalization:
|
27
|
+
/.bundle
|
28
|
+
/vendor/bundle
|
29
|
+
|
30
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
31
|
+
.rvmrc
|
32
|
+
|
33
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
34
|
+
/vendor/assets/bower_components
|
35
|
+
*.bowerrc
|
36
|
+
bower.json
|
37
|
+
|
38
|
+
# Ignore pow environment settings
|
39
|
+
.powenv
|
40
|
+
|
41
|
+
# Ignore Byebug command history file.
|
42
|
+
.byebug_history
|
data/.hound.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.0
|
4
|
+
DisplayCopNames: true
|
5
|
+
Exclude:
|
6
|
+
- 'tmp/**/*'
|
7
|
+
|
8
|
+
Style/MixinGrouping:
|
9
|
+
Exclude:
|
10
|
+
- 'spec/**/*.rb'
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
CountComments: false # count full line comments?
|
14
|
+
Exclude:
|
15
|
+
- '**/*_spec.rb'
|
16
|
+
|
17
|
+
StringLiterals:
|
18
|
+
EnforcedStyle: single_quotes
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
DotPosition:
|
22
|
+
Description: 'Checks the position of the dot in multi-line method calls.'
|
23
|
+
EnforcedStyle: leading
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
ClassAndModuleChildren:
|
27
|
+
Description: 'Checks style of children classes and modules.'
|
28
|
+
EnforcedStyle: nested
|
29
|
+
Enabled: true
|
30
|
+
|
31
|
+
Documentation:
|
32
|
+
Description: 'Document classes and non-namespace modules.'
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
FileName:
|
36
|
+
Description: 'Use snake_case for source file names.'
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
LineLength:
|
40
|
+
Max: 120
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
Style/ExtraSpacing:
|
44
|
+
Description: 'Do not use unnecessary spacing.'
|
45
|
+
Enabled: true
|
46
|
+
|
47
|
+
Lint/LiteralInInterpolation:
|
48
|
+
Description: 'Avoid interpolating literals in strings'
|
49
|
+
AutoCorrect: true
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
### Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
|
12
|
+
|
13
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
14
|
+
|
15
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.1.0, available at [http://contributor-covenant.org/version/1/1/0/](http://contributor-covenant.org/version/1/1/0/)
|
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
gemspec
|
5
|
+
ruby RUBY_VERSION
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'bundler'
|
9
|
+
gem 'gem-release'
|
10
|
+
gem 'guard'
|
11
|
+
gem 'guard-rspec'
|
12
|
+
gem 'guard-rubocop'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :test do
|
16
|
+
gem 'coveralls'
|
17
|
+
gem 'fuubar'
|
18
|
+
gem 'rake' # Workaround for a bug in Rainbow 2.2.1 https://github.com/sickill/rainbow/issues/44
|
19
|
+
gem 'rspec'
|
20
|
+
gem 'rspec_junit_formatter'
|
21
|
+
gem 'simplecov', '~> 0.13'
|
22
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
guard :rubocop do
|
4
|
+
watch(/.+\.rb$/)
|
5
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
6
|
+
end
|
7
|
+
|
8
|
+
guard(
|
9
|
+
:rspec,
|
10
|
+
all_after_pass: true,
|
11
|
+
all_on_start: true,
|
12
|
+
cmd: 'NO_SIMPLECOV=true bundle exec rspec --fail-fast --format documentation'
|
13
|
+
) do
|
14
|
+
watch(%r{spec/.+_spec\.rb$})
|
15
|
+
watch(%r{lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
16
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
17
|
+
watch(%r{^spec/support/.+\.rb$}) { 'spec' }
|
18
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dominic Sayers
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
## Loglevel
|
2
|
+
|
3
|
+
[![Gem version](https://badge.fury.io/rb/loglevel.svg)](https://rubygems.org/gems/loglevel)
|
4
|
+
[![Gem downloads](https://img.shields.io/gem/dt/loglevel.svg)](https://rubygems.org/gems/loglevel)
|
5
|
+
[![Build Status](https://travis-ci.org/dominicsayers/loglevel.svg?branch=master)](https://travis-ci.org/dominicsayers/loglevel)
|
6
|
+
[![Code quality](http://img.shields.io/codeclimate/github/dominicsayers/loglevel.svg?style=flat)](https://codeclimate.com/github/dominicsayers/loglevel)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/github/dominicsayers/loglevel/badge.svg?branch=master)](https://coveralls.io/github/dominicsayers/loglevel?branch=master)
|
8
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/dominicsayers/loglevel.svg)](https://gemnasium.com/github.com/dominicsayers/loglevel)
|
9
|
+
[![Security](https://hakiri.io/github/dominicsayers/loglevel/master.svg)](https://hakiri.io/github/dominicsayers/loglevel/master)
|
10
|
+
|
11
|
+
Control logging at runtime with an environment variable
|
12
|
+
|
13
|
+
Usage:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
LOGLEVEL=WARN rails server
|
17
|
+
```
|
18
|
+
|
19
|
+
### Features
|
20
|
+
|
21
|
+
Control which components create visible log entries by simply setting an
|
22
|
+
environment variable. For instance:
|
23
|
+
|
24
|
+
```sh
|
25
|
+
LOGLEVEL=DEBUG,NOAR,NOHTTP rails server
|
26
|
+
```
|
27
|
+
|
28
|
+
would set the Rails logger level to `:debug` but would suppress messages from
|
29
|
+
the ActiveRecord logger and the HttpLogger gem.
|
30
|
+
|
31
|
+
The features are itemized if you use the `HELP` option:
|
32
|
+
|
33
|
+
```sh
|
34
|
+
LOGLEVEL=HELP rails console
|
35
|
+
```
|
36
|
+
|
37
|
+
Here are the available settings:
|
38
|
+
|
39
|
+
| Option | Description |
|
40
|
+
| --------- | ------------------------------------------- |
|
41
|
+
| HELP | Show these options |
|
42
|
+
| FATAL | Equivalent to config.log_level = :fatal |
|
43
|
+
| ERROR | Equivalent to config.log_level = :error |
|
44
|
+
| WARN | Equivalent to config.log_level = :warn |
|
45
|
+
| INFO | Equivalent to config.log_level = :info |
|
46
|
+
| DEBUG | Equivalent to config.log_level = :debug |
|
47
|
+
| NOAR | Do not show ActiveRecord messages |
|
48
|
+
| NOHTTP | Do not show HTTP messages |
|
49
|
+
| NOHEADERS | Do not include response headers in HTTP log |
|
50
|
+
| NOBODY | Do not include response body in HTTP log |
|
51
|
+
|
52
|
+
### Dependencies
|
53
|
+
|
54
|
+
The examples in this document assume Loglevel is being used in a Rails
|
55
|
+
environment but it doesn't depend on Rails and can be used in other contexts.
|
56
|
+
|
57
|
+
There are specific options to handle Railsy logging scenarios: things like
|
58
|
+
controlling ActiveRecord logging. There are also specific options for handling
|
59
|
+
the HttpLogger gem.
|
60
|
+
|
61
|
+
### Logger
|
62
|
+
|
63
|
+
By default Loglevel will instantiate Ruby's default Logger class. If you want to
|
64
|
+
use a different logger then you can use an environment variable to tell Loglevel
|
65
|
+
which logger you use:
|
66
|
+
|
67
|
+
```sh
|
68
|
+
LOGLEVEL_LOGGER=Log4r LOGLEVEL=DEBUG rails server
|
69
|
+
```
|
70
|
+
|
71
|
+
### Log device
|
72
|
+
|
73
|
+
By default Loglevel will setup logging to the `STDOUT` device. If you want to
|
74
|
+
use a different device there's an environment variable for that:
|
75
|
+
|
76
|
+
```sh
|
77
|
+
LOGLEVEL_DEVICE=tmp/test.log LOGLEVEL=DEBUG rails server
|
78
|
+
```
|
79
|
+
|
80
|
+
### Classes with a logger
|
81
|
+
|
82
|
+
By default, Loglevel will setup the logger for Rails, ActiveRecord::Base and
|
83
|
+
HttpLogger if they are present.
|
84
|
+
|
85
|
+
It will also setup logging for any other classes that you include in an
|
86
|
+
environment variable:
|
87
|
+
|
88
|
+
```sh
|
89
|
+
LOGLEVEL_CLASSES=MyClass LOGLEVEL=DEBUG rails server
|
90
|
+
```
|
91
|
+
|
92
|
+
The only methods the class must support are `logger` and `logger=`
|
93
|
+
|
94
|
+
### Contributing
|
95
|
+
|
96
|
+
[![Developer](http://img.shields.io/badge/developer-awesome-brightgreen.svg?style=flat)](https://www.dominicsayers.com)
|
97
|
+
|
98
|
+
1. Fork it
|
99
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
100
|
+
1. Commit your changes (`git commit -am 'Add some feature'`)
|
101
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
102
|
+
1. Create new Pull Request
|
data/Rakefile
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
machine:
|
3
|
+
ruby:
|
4
|
+
version: '2.0'
|
5
|
+
dependencies:
|
6
|
+
pre:
|
7
|
+
- echo "export rvm_ignore_gemsets_flag=1" >> ~/.rvmrc
|
8
|
+
- gem update --system
|
9
|
+
- gem install bundler
|
10
|
+
test:
|
11
|
+
override:
|
12
|
+
- RAILS_ENV=test bundle exec rspec -r rspec_junit_formatter --format RspecJunitFormatter -o $CIRCLE_TEST_REPORTS/rspec/junit.xml:
|
13
|
+
parallel: true
|
14
|
+
files:
|
15
|
+
- spec/**/*.rb
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# ActiveRecord-specific settings
|
2
|
+
module Loglevel
|
3
|
+
module ActiveRecord
|
4
|
+
def active_record?
|
5
|
+
!lookup('NOAR')
|
6
|
+
end
|
7
|
+
|
8
|
+
def setup_active_record
|
9
|
+
return unless defined?(::ActiveRecord::Base) && classes.delete(::ActiveRecord::Base)
|
10
|
+
active_record? ? setup_active_record_logger_to_log : setup_active_record_logger_not_to_log
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup_active_record_logger_to_log
|
14
|
+
::ActiveRecord::Base.logger = logger
|
15
|
+
::ActiveRecord::Base.logger.level = log_level
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup_active_record_logger_not_to_log
|
19
|
+
::ActiveRecord::Base.logger = null_logger
|
20
|
+
::ActiveRecord::Base.logger.level = logger_class::FATAL
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Loglevel
|
2
|
+
class Classes
|
3
|
+
attr_reader :classes
|
4
|
+
|
5
|
+
def stringify
|
6
|
+
@stringify ||= classes.map(&:name)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@classes = class_names.map do |class_name|
|
13
|
+
begin
|
14
|
+
Object.const_get("::#{class_name}")
|
15
|
+
rescue NameError # Uninitialized constant
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
end.compact
|
19
|
+
end
|
20
|
+
|
21
|
+
def class_names
|
22
|
+
@class_names ||= passed_class_names | %w(Rails ActiveRecord::Base HttpLogger)
|
23
|
+
end
|
24
|
+
|
25
|
+
def passed_class_names
|
26
|
+
@passed_class_names ||= ENV.fetch(Loglevel::ENV_VAR_CLASSES, '').gsub(/[[:space:]]/, '').split(',')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Help
|
2
|
+
module Loglevel
|
3
|
+
module Help
|
4
|
+
def help?
|
5
|
+
lookup('HELP') || settings == ['TRUE']
|
6
|
+
end
|
7
|
+
|
8
|
+
def help
|
9
|
+
logger.info <<-HELP
|
10
|
+
Usage: DEBUG=SETTING,SETTING,SETTING rails server
|
11
|
+
|
12
|
+
Available settings are as follows:
|
13
|
+
HELP Show these options
|
14
|
+
FATAL Equivalent to config.log_level = :fatal
|
15
|
+
ERROR Equivalent to config.log_level = :error
|
16
|
+
WARN Equivalent to config.log_level = :warn
|
17
|
+
INFO Equivalent to config.log_level = :info
|
18
|
+
DEBUG Equivalent to config.log_level = :debug
|
19
|
+
NOAR Do not show ActiveRecord messages
|
20
|
+
NOHTTP Do not show HTTP messages
|
21
|
+
NOHEADERS Do not include response headers in HTTP log
|
22
|
+
NOBODY Do not include response body in HTTP log
|
23
|
+
|
24
|
+
HTTP messages will only be shown if http_logger gem is present
|
25
|
+
HELP
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# HttpLogger-specific settings
|
2
|
+
module Loglevel
|
3
|
+
module HttpLogger
|
4
|
+
def http?
|
5
|
+
!lookup('NOHTTP')
|
6
|
+
end
|
7
|
+
|
8
|
+
def response_body?
|
9
|
+
!lookup('NOBODY')
|
10
|
+
end
|
11
|
+
|
12
|
+
def request_headers?
|
13
|
+
!lookup('NOHEADERS')
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup_http_logger
|
17
|
+
return unless defined?(::HttpLogger) && classes.delete(::HttpLogger)
|
18
|
+
http? ? setup_http_logger_to_log : setup_http_logger_not_to_log
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup_http_logger_to_log
|
22
|
+
::HttpLogger.logger = logger
|
23
|
+
::HttpLogger.level = log_level_name.downcase.to_sym
|
24
|
+
::HttpLogger.log_response_body = response_body?
|
25
|
+
::HttpLogger.log_headers = request_headers?
|
26
|
+
::HttpLogger.ignore = [/9200/, /7474/] # ignore Elasticsearch & Neo4J
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_http_logger_not_to_log
|
30
|
+
::HttpLogger.logger = null_logger
|
31
|
+
::HttpLogger.level = :fatal
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/loglevel.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'loglevel/classes'
|
2
|
+
require 'loglevel/active_record'
|
3
|
+
require 'loglevel/http_logger'
|
4
|
+
require 'loglevel/help'
|
5
|
+
|
6
|
+
module Loglevel
|
7
|
+
ENV_VAR_LEVEL = 'LOGLEVEL'.freeze
|
8
|
+
ENV_VAR_LOGGER = 'LOGLEVEL_LOGGER'.freeze
|
9
|
+
ENV_VAR_DEVICE = 'LOGLEVEL_DEVICE'.freeze
|
10
|
+
ENV_VAR_CLASSES = 'LOGLEVEL_CLASSES'.freeze
|
11
|
+
LOG_LEVELS = %w(DEBUG INFO WARN ERROR FATAL UNKNOWN).freeze
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_reader :classes
|
15
|
+
attr_writer :logger
|
16
|
+
|
17
|
+
def setup
|
18
|
+
return unless ENV[ENV_VAR_LEVEL]
|
19
|
+
|
20
|
+
@classes = Loglevel::Classes.new.classes
|
21
|
+
@settings = nil
|
22
|
+
@logger = nil
|
23
|
+
@log_level = nil
|
24
|
+
|
25
|
+
setup_active_record
|
26
|
+
setup_http_logger
|
27
|
+
setup_remaining_classes
|
28
|
+
|
29
|
+
help if help?
|
30
|
+
end
|
31
|
+
|
32
|
+
def logger
|
33
|
+
@logger ||= logger_class.new log_device
|
34
|
+
end
|
35
|
+
|
36
|
+
def log_level
|
37
|
+
@log_level ||= logger_class.const_get log_level_name
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
include Loglevel::ActiveRecord
|
43
|
+
include Loglevel::HttpLogger
|
44
|
+
include Loglevel::Help
|
45
|
+
|
46
|
+
# Setup any other classes (e.g. Rails)
|
47
|
+
def setup_remaining_classes
|
48
|
+
classes.each do |klass|
|
49
|
+
klass.logger = logger
|
50
|
+
klass.logger.level = log_level
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def log_level_name
|
55
|
+
(LOG_LEVELS & settings).first || 'INFO'
|
56
|
+
end
|
57
|
+
|
58
|
+
def logger_class
|
59
|
+
Object.const_get ENV.fetch(ENV_VAR_LOGGER, 'Logger')
|
60
|
+
end
|
61
|
+
|
62
|
+
def log_device
|
63
|
+
%w(STDOUT STDERR).include?(log_device_name) ? Object.const_get(log_device_name) : log_device_name
|
64
|
+
end
|
65
|
+
|
66
|
+
def log_device_name
|
67
|
+
ENV.fetch(ENV_VAR_DEVICE, 'STDOUT')
|
68
|
+
end
|
69
|
+
|
70
|
+
# Implementing as a method in case someone wants to detect the OS and make
|
71
|
+
# an OS-dependent null device
|
72
|
+
def null_device
|
73
|
+
@null_device ||= '/dev/null'
|
74
|
+
end
|
75
|
+
|
76
|
+
def null_logger
|
77
|
+
@null_logger ||= logger_class.new null_device
|
78
|
+
end
|
79
|
+
|
80
|
+
def settings
|
81
|
+
@settings ||= ENV.fetch(ENV_VAR_LEVEL, '').upcase.split(',')
|
82
|
+
end
|
83
|
+
|
84
|
+
def lookup(setting)
|
85
|
+
settings.include?(setting)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
Loglevel.setup
|
data/loglevel.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'loglevel/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'loglevel'
|
9
|
+
spec.version = Loglevel::VERSION
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.required_ruby_version = '>= 2.0.0'
|
12
|
+
spec.authors = ['Dominic Sayers']
|
13
|
+
spec.email = ['dominic@sayers.cc']
|
14
|
+
spec.description = 'A simple gem to interact with Mailchimp through their API v3'
|
15
|
+
spec.summary = 'Example: mailchimp.lists("My first list").member("ann@example.com")'
|
16
|
+
spec.homepage = 'https://github.com/dominicsayers/loglevel'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
20
|
+
spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features|coverage|script)\/})
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
RSpec.describe Loglevel::ActiveRecord do
|
4
|
+
before do
|
5
|
+
class MyClass
|
6
|
+
class << self
|
7
|
+
attr_accessor :logger
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Rails < MyClass; end
|
12
|
+
|
13
|
+
module ActiveRecord
|
14
|
+
class Base < Rails; end
|
15
|
+
end
|
16
|
+
|
17
|
+
class HttpLogger < Rails
|
18
|
+
class << self
|
19
|
+
attr_accessor :level, :log_response_body, :log_headers, :ignore
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
Object.send(:remove_const, :MyClass)
|
26
|
+
Object.send(:remove_const, :Rails)
|
27
|
+
Object.send(:remove_const, :ActiveRecord)
|
28
|
+
Object.send(:remove_const, :HttpLogger)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'NOAR' do
|
32
|
+
before do
|
33
|
+
ENV.store Loglevel::ENV_VAR_LEVEL, 'noAR' # the capitalization is intentional
|
34
|
+
Loglevel.setup
|
35
|
+
end
|
36
|
+
|
37
|
+
after { ENV.delete Loglevel::ENV_VAR_LEVEL }
|
38
|
+
|
39
|
+
it 'has the expected ActiveRecord settings' do
|
40
|
+
expect(::ActiveRecord::Base.logger).to eq Loglevel.send(:null_logger)
|
41
|
+
expect(::ActiveRecord::Base.logger.level).to eq Logger.const_get('FATAL')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
RSpec.describe Loglevel::Classes do
|
2
|
+
context 'default classes' do
|
3
|
+
it 'is empty unless classes are available' do
|
4
|
+
expect(Loglevel::Classes.new.classes).to be_empty
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'returns available classes' do
|
8
|
+
class Rails; end
|
9
|
+
class HttpLogger; end
|
10
|
+
|
11
|
+
classes = Loglevel::Classes.new
|
12
|
+
expect(classes.classes).to include(Rails, HttpLogger)
|
13
|
+
expect(classes.stringify).to include('Rails', 'HttpLogger')
|
14
|
+
expect(classes.stringify).not_to include('ActiveRecord::Base')
|
15
|
+
|
16
|
+
Object.send(:remove_const, :Rails)
|
17
|
+
Object.send(:remove_const, :HttpLogger)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'classes from environment variable' do
|
22
|
+
before { ENV.store Loglevel::ENV_VAR_CLASSES, 'String,Array , Hash,MyClass' } # the spaces are intentional
|
23
|
+
after { ENV.delete Loglevel::ENV_VAR_CLASSES }
|
24
|
+
|
25
|
+
it 'returns classes that exist' do
|
26
|
+
classes = Loglevel::Classes.new
|
27
|
+
expect(classes.classes).to include(String, Array, Hash)
|
28
|
+
expect(classes.stringify).not_to include('MyClass')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns defined classes' do
|
32
|
+
class MyClass; end
|
33
|
+
|
34
|
+
module ActiveRecord
|
35
|
+
class Base; end
|
36
|
+
end
|
37
|
+
|
38
|
+
expect(Loglevel::Classes.new.classes).to include(ActiveRecord::Base, String, Array, Hash, MyClass)
|
39
|
+
|
40
|
+
Object.send(:remove_const, :MyClass)
|
41
|
+
Object.send(:remove_const, :ActiveRecord)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
RSpec.describe Loglevel::Help do
|
2
|
+
context 'HELP' do
|
3
|
+
before do
|
4
|
+
class MyLogger
|
5
|
+
INFO = 1
|
6
|
+
attr_accessor :level
|
7
|
+
|
8
|
+
def initialize(device); end
|
9
|
+
|
10
|
+
def info(message); end
|
11
|
+
end
|
12
|
+
|
13
|
+
ENV.store Loglevel::ENV_VAR_LOGGER, 'MyLogger'
|
14
|
+
ENV.store Loglevel::ENV_VAR_LEVEL, 'Help' # the capitalization is intentional
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
ENV.delete Loglevel::ENV_VAR_LOGGER
|
19
|
+
ENV.delete Loglevel::ENV_VAR_LEVEL
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has the expected ActiveRecord settings' do
|
23
|
+
expect_any_instance_of(MyLogger).to receive(:info).once
|
24
|
+
Loglevel.setup
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
RSpec.describe Loglevel::HttpLogger do
|
4
|
+
before do
|
5
|
+
class MyClass
|
6
|
+
class << self
|
7
|
+
attr_accessor :logger
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Rails < MyClass; end
|
12
|
+
|
13
|
+
module ActiveRecord
|
14
|
+
class Base < Rails; end
|
15
|
+
end
|
16
|
+
|
17
|
+
class HttpLogger < Rails
|
18
|
+
class << self
|
19
|
+
attr_accessor :level, :log_response_body, :log_headers, :ignore
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
Object.send(:remove_const, :MyClass)
|
26
|
+
Object.send(:remove_const, :Rails)
|
27
|
+
Object.send(:remove_const, :ActiveRecord)
|
28
|
+
Object.send(:remove_const, :HttpLogger)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'NOHTTP' do
|
32
|
+
before do
|
33
|
+
ENV.store Loglevel::ENV_VAR_LEVEL, 'noHttp' # the capitalization is intentional
|
34
|
+
Loglevel.setup
|
35
|
+
end
|
36
|
+
|
37
|
+
after { ENV.delete Loglevel::ENV_VAR_LEVEL }
|
38
|
+
|
39
|
+
it 'has the expected HttpLogger settings' do
|
40
|
+
expect(::HttpLogger.logger).to eq Loglevel.send(:null_logger)
|
41
|
+
expect(::HttpLogger.level).to eq :fatal
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
RSpec.describe Loglevel do
|
4
|
+
before do
|
5
|
+
class MyClass
|
6
|
+
class << self
|
7
|
+
attr_accessor :logger
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Rails < MyClass; end
|
12
|
+
|
13
|
+
module ActiveRecord
|
14
|
+
class Base < Rails; end
|
15
|
+
end
|
16
|
+
|
17
|
+
class HttpLogger < Rails
|
18
|
+
class << self
|
19
|
+
attr_accessor :level, :log_response_body, :log_headers, :ignore
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
Object.send(:remove_const, :MyClass)
|
26
|
+
Object.send(:remove_const, :Rails)
|
27
|
+
Object.send(:remove_const, :ActiveRecord)
|
28
|
+
Object.send(:remove_const, :HttpLogger)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'no environment variable' do
|
32
|
+
before { Loglevel.setup }
|
33
|
+
|
34
|
+
it 'has the expected logger class' do
|
35
|
+
expect(Loglevel.send(:logger_class)).to eq Loglevel.send(:logger_class)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'has the expected device' do
|
39
|
+
expect(Loglevel.send(:log_device)).to eq STDOUT
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has the expected log level' do
|
43
|
+
expect(Rails.logger).to be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'has the expected ActiveRecord::Base settings' do
|
47
|
+
expect(::ActiveRecord::Base.logger).to be_nil
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'has the expected HttpLogger settings' do
|
51
|
+
expect(::HttpLogger.level).to be_nil
|
52
|
+
expect(::HttpLogger.log_response_body).to be_nil
|
53
|
+
expect(::HttpLogger.log_headers).to be_nil
|
54
|
+
expect(::HttpLogger.ignore).to be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'defaults' do
|
59
|
+
before do
|
60
|
+
ENV.store Loglevel::ENV_VAR_LEVEL, 'INFO'
|
61
|
+
Loglevel.setup
|
62
|
+
end
|
63
|
+
|
64
|
+
after { ENV.delete Loglevel::ENV_VAR_LEVEL }
|
65
|
+
|
66
|
+
it 'has the expected logger class' do
|
67
|
+
expect(Loglevel.send(:logger_class)).to eq ::Logger
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'has the expected device' do
|
71
|
+
expect(Loglevel.send(:log_device)).to eq STDOUT
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'has the expected log level' do
|
75
|
+
expect(Rails.logger).to eq Loglevel.logger
|
76
|
+
expect(Rails.logger.level).to eq Logger.const_get('INFO')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'has the expected ActiveRecord::Base settings' do
|
80
|
+
expect(::ActiveRecord::Base.logger).to eq Loglevel.logger
|
81
|
+
expect(::ActiveRecord::Base.logger.level).to eq Logger.const_get('INFO')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'has the expected HttpLogger settings' do
|
85
|
+
expect(::HttpLogger.level).to eq :info
|
86
|
+
expect(::HttpLogger.log_response_body).to be_truthy
|
87
|
+
expect(::HttpLogger.log_headers).to be_truthy
|
88
|
+
expect(::HttpLogger.ignore).to include(/9200/, /7474/)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'variations' do
|
93
|
+
before do
|
94
|
+
class MyLogger
|
95
|
+
INFO = 1
|
96
|
+
WARN = 2
|
97
|
+
FATAL = 4
|
98
|
+
attr_accessor :level
|
99
|
+
def initialize(device); end
|
100
|
+
end
|
101
|
+
|
102
|
+
ENV.store Loglevel::ENV_VAR_LOGGER, 'MyLogger'
|
103
|
+
ENV.store Loglevel::ENV_VAR_DEVICE, 'STDERR'
|
104
|
+
end
|
105
|
+
|
106
|
+
after do
|
107
|
+
ENV.delete Loglevel::ENV_VAR_LEVEL
|
108
|
+
ENV.delete Loglevel::ENV_VAR_LOGGER
|
109
|
+
ENV.delete Loglevel::ENV_VAR_DEVICE
|
110
|
+
Object.send(:remove_const, :MyLogger)
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'HTTP and ActiveRecord' do
|
114
|
+
before do
|
115
|
+
ENV.store Loglevel::ENV_VAR_LEVEL, 'WARN'
|
116
|
+
Loglevel.setup
|
117
|
+
end
|
118
|
+
|
119
|
+
after do
|
120
|
+
ENV.delete Loglevel::ENV_VAR_LEVEL
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'has the expected logger class' do
|
124
|
+
expect(Loglevel.send(:logger_class)).to eq ::MyLogger
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'has the expected device' do
|
128
|
+
expect(Loglevel.send(:log_device)).to eq STDERR
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'has the expected log level' do
|
132
|
+
expect(Rails.logger).to eq Loglevel.logger
|
133
|
+
expect(Rails.logger.level).to eq Logger.const_get('WARN')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'HTTP but not ActiveRecord' do
|
138
|
+
before do
|
139
|
+
ENV.store Loglevel::ENV_VAR_LEVEL, 'WARN,NOBODY,NOHEADERS,NOAR'
|
140
|
+
Loglevel.setup
|
141
|
+
end
|
142
|
+
|
143
|
+
after do
|
144
|
+
ENV.delete Loglevel::ENV_VAR_LEVEL
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'has the expected ActiveRecord::Base settings' do
|
148
|
+
expect(::ActiveRecord::Base.logger).to eq Loglevel.send(:null_logger)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'has the expected HttpLogger settings' do
|
152
|
+
expect(::HttpLogger.level).to eq :warn
|
153
|
+
expect(::HttpLogger.log_response_body).to be_falsey
|
154
|
+
expect(::HttpLogger.log_headers).to be_falsey
|
155
|
+
expect(::HttpLogger.ignore).to include(/9200/, /7474/)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'ActiveRecord but not HTTP' do
|
160
|
+
before do
|
161
|
+
ENV.store Loglevel::ENV_VAR_LEVEL, 'WARN,NOHTTP'
|
162
|
+
Loglevel.setup
|
163
|
+
end
|
164
|
+
|
165
|
+
after do
|
166
|
+
ENV.delete Loglevel::ENV_VAR_LEVEL
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'has the expected ActiveRecord::Base settings' do
|
170
|
+
expect(::ActiveRecord::Base.logger).to eq Loglevel.logger
|
171
|
+
expect(::ActiveRecord::Base.logger.level).to eq Logger.const_get('WARN')
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'has the expected HttpLogger settings' do
|
175
|
+
expect(::HttpLogger.level).to eq :fatal
|
176
|
+
expect(::HttpLogger.log_response_body).to be_falsey
|
177
|
+
expect(::HttpLogger.log_headers).to be_falsey
|
178
|
+
expect(::HttpLogger.ignore).to be_nil
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Configure Simplecov and Coveralls
|
2
|
+
unless ENV['NO_SIMPLECOV']
|
3
|
+
require 'simplecov'
|
4
|
+
require 'coveralls'
|
5
|
+
|
6
|
+
SimpleCov.start { add_filter '/spec/' }
|
7
|
+
Coveralls.wear! if ENV['COVERALLS_REPO_TOKEN']
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'loglevel'
|
11
|
+
|
12
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
13
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
14
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
15
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
16
|
+
# files.
|
17
|
+
#
|
18
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
19
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
20
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
21
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
22
|
+
# a separate helper file that requires the additional dependencies and performs
|
23
|
+
# the additional setup, and require it from the spec files that actually need
|
24
|
+
# it.
|
25
|
+
#
|
26
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
27
|
+
# users commonly want.
|
28
|
+
#
|
29
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
30
|
+
RSpec.configure do |config|
|
31
|
+
# rspec-expectations config goes here. You can use an alternate
|
32
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
33
|
+
# assertions if you prefer.
|
34
|
+
config.expect_with :rspec do |expectations|
|
35
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
36
|
+
# and `failure_message` of custom matchers include text for helper methods
|
37
|
+
# defined using `chain`, e.g.:
|
38
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
39
|
+
# # => "be bigger than 2 and smaller than 4"
|
40
|
+
# ...rather than:
|
41
|
+
# # => "be bigger than 2"
|
42
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
43
|
+
end
|
44
|
+
|
45
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
46
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
47
|
+
config.mock_with :rspec do |mocks|
|
48
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
49
|
+
# a real object. This is generally recommended, and will default to
|
50
|
+
# `true` in RSpec 4.
|
51
|
+
mocks.verify_partial_doubles = true
|
52
|
+
end
|
53
|
+
|
54
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
55
|
+
# have no way to turn it off -- the option exists only for backwards
|
56
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
57
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
58
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
59
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
60
|
+
|
61
|
+
# This allows you to limit a spec run to individual examples or groups
|
62
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
63
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
64
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
65
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
66
|
+
config.filter_run_when_matching :focus
|
67
|
+
|
68
|
+
# Allows RSpec to persist some state between runs in order to support
|
69
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
70
|
+
# you configure your source control system to ignore this file.
|
71
|
+
config.example_status_persistence_file_path = 'tmp/rspec/examples.txt'
|
72
|
+
|
73
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
74
|
+
# recommended. For more details, see:
|
75
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
76
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
77
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
78
|
+
config.disable_monkey_patching!
|
79
|
+
|
80
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
81
|
+
# be too noisy due to issues in dependencies.
|
82
|
+
config.warnings = true
|
83
|
+
|
84
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
85
|
+
# file, and it's useful to allow more verbose output when running an
|
86
|
+
# individual spec file.
|
87
|
+
if config.files_to_run.one?
|
88
|
+
# Use the documentation formatter for detailed output,
|
89
|
+
# unless a formatter has already been configured
|
90
|
+
# (e.g. via a command-line flag).
|
91
|
+
config.default_formatter = 'doc'
|
92
|
+
end
|
93
|
+
|
94
|
+
# Print the 10 slowest examples and example groups at the
|
95
|
+
# end of the spec run, to help surface which specs are running
|
96
|
+
# particularly slow.
|
97
|
+
config.profile_examples = 10
|
98
|
+
|
99
|
+
# Run specs in random order to surface order dependencies. If you find an
|
100
|
+
# order dependency and want to debug it, you can fix the order by providing
|
101
|
+
# the seed, which is printed after each run.
|
102
|
+
# --seed 1234
|
103
|
+
config.order = :random
|
104
|
+
|
105
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
106
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
107
|
+
# test failures related to randomization by passing the same `--seed` value
|
108
|
+
# as the one that triggered the failure.
|
109
|
+
Kernel.srand config.seed
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: loglevel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dominic Sayers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple gem to interact with Mailchimp through their API v3
|
14
|
+
email:
|
15
|
+
- dominic@sayers.cc
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- .hound.yml
|
22
|
+
- .rspec
|
23
|
+
- .rubocop.yml
|
24
|
+
- .travis.yml
|
25
|
+
- CODE_OF_CONDUCT.md
|
26
|
+
- Gemfile
|
27
|
+
- Guardfile
|
28
|
+
- LICENSE
|
29
|
+
- README.md
|
30
|
+
- Rakefile
|
31
|
+
- circle.yml
|
32
|
+
- lib/loglevel.rb
|
33
|
+
- lib/loglevel/active_record.rb
|
34
|
+
- lib/loglevel/classes.rb
|
35
|
+
- lib/loglevel/help.rb
|
36
|
+
- lib/loglevel/http_logger.rb
|
37
|
+
- lib/loglevel/version.rb
|
38
|
+
- loglevel.gemspec
|
39
|
+
- script/console
|
40
|
+
- spec/loglevel/active_record_spec.rb
|
41
|
+
- spec/loglevel/classes_spec.rb
|
42
|
+
- spec/loglevel/help_spec.rb
|
43
|
+
- spec/loglevel/http_logger_spec.rb
|
44
|
+
- spec/loglevel_spec.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
homepage: https://github.com/dominicsayers/loglevel
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 2.0.0
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.4.8
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: 'Example: mailchimp.lists("My first list").member("ann@example.com")'
|
70
|
+
test_files:
|
71
|
+
- script/console
|
72
|
+
- spec/loglevel/active_record_spec.rb
|
73
|
+
- spec/loglevel/classes_spec.rb
|
74
|
+
- spec/loglevel/help_spec.rb
|
75
|
+
- spec/loglevel/http_logger_spec.rb
|
76
|
+
- spec/loglevel_spec.rb
|
77
|
+
- spec/spec_helper.rb
|