sinatra-sane-logging 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dbd75edc6649f3340fecad63ce03eee25141bdac
4
+ data.tar.gz: f9ca5f4e76ab2d9c61c34b706edf0f5571fccad7
5
+ SHA512:
6
+ metadata.gz: c03c81177cfeccc9ec3a2347859e2276a7ed0730798d5f1c52b0b3b0eba5bc168cffd9fb8be6a05991c4afea6c908fa5de356598fb5f0aa0c52bdfbcf5aaee92
7
+ data.tar.gz: b5735974e1b7b404f9ae55f789c3ede75fb4dd84231aeff6acfde617bd07680a35d29b65c94cb6a9cf61bb2c66a073ecd8eaa6758e701c346c2f56ffc93b373f
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /coverage/
2
+ /pkg/
3
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,42 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Documentation:
5
+ Enabled: false
6
+
7
+ Metrics/BlockLength:
8
+ Max: 32
9
+ Exclude:
10
+ - "spec/**/*.rb"
11
+
12
+ Metrics/LineLength:
13
+ Max: 120
14
+
15
+ Style/AndOr:
16
+ EnforcedStyle: conditionals
17
+
18
+ Style/Encoding:
19
+ EnforcedStyle: when_needed
20
+
21
+ Style/FrozenStringLiteralComment:
22
+ Enabled: false
23
+
24
+ Style/IndentHash:
25
+ Enabled: false
26
+
27
+ Style/PercentLiteralDelimiters:
28
+ PreferredDelimiters:
29
+ "%i": "[]"
30
+ "%I": "[]"
31
+ "%w": "[]"
32
+ "%W": "[]"
33
+
34
+ Style/RedundantSelf:
35
+ Enabled: false
36
+
37
+ Style/SignalException:
38
+ Enabled: true
39
+ EnforcedStyle: semantic
40
+
41
+ Style/StringLiterals:
42
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.1.0
2
+
3
+ * initial release
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ja AT jestem DOT tw. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Dockerfile ADDED
@@ -0,0 +1,13 @@
1
+ FROM ruby:2.4.0-alpine
2
+
3
+ RUN apk --update --no-cache add build-base git openssh-client && \
4
+ mkdir /sinatra-sane-logging && \
5
+ gem install bundler -v 1.13.7
6
+
7
+ WORKDIR /sinatra-sane-logging
8
+
9
+ COPY sinatra-sane-logging.gemspec Gemfile Gemfile.lock ./
10
+
11
+ RUN bundle
12
+
13
+ COPY . ./
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sinatra-sane-logging (0.1.0)
5
+ sinatra
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.3.0)
11
+ coderay (1.1.1)
12
+ diff-lcs (1.3)
13
+ docile (1.1.5)
14
+ json (2.0.3)
15
+ method_source (0.8.2)
16
+ parser (2.4.0.0)
17
+ ast (~> 2.2)
18
+ powerpack (0.1.1)
19
+ pry (0.10.4)
20
+ coderay (~> 1.1.0)
21
+ method_source (~> 0.8.1)
22
+ slop (~> 3.4)
23
+ rack (1.6.5)
24
+ rack-protection (1.5.3)
25
+ rack
26
+ rack-test (0.6.3)
27
+ rack (>= 1.0)
28
+ rainbow (2.2.1)
29
+ rake (12.0.0)
30
+ rspec (3.5.0)
31
+ rspec-core (~> 3.5.0)
32
+ rspec-expectations (~> 3.5.0)
33
+ rspec-mocks (~> 3.5.0)
34
+ rspec-core (3.5.4)
35
+ rspec-support (~> 3.5.0)
36
+ rspec-expectations (3.5.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.5.0)
39
+ rspec-mocks (3.5.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.5.0)
42
+ rspec-support (3.5.0)
43
+ rubocop (0.47.1)
44
+ parser (>= 2.3.3.1, < 3.0)
45
+ powerpack (~> 0.1)
46
+ rainbow (>= 1.99.1, < 3.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (~> 1.0, >= 1.0.1)
49
+ ruby-progressbar (1.8.1)
50
+ simplecov (0.13.0)
51
+ docile (~> 1.1.0)
52
+ json (>= 1.8, < 3)
53
+ simplecov-html (~> 0.10.0)
54
+ simplecov-html (0.10.0)
55
+ sinatra (1.4.8)
56
+ rack (~> 1.5)
57
+ rack-protection (~> 1.4)
58
+ tilt (>= 1.3, < 3)
59
+ slop (3.6.0)
60
+ tilt (2.0.6)
61
+ unicode-display_width (1.1.3)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ bundler (~> 1.13)
68
+ pry
69
+ rack-test
70
+ rake (~> 12.0)
71
+ rspec (~> 3.5)
72
+ rubocop (~> 0)
73
+ simplecov (~> 0)
74
+ sinatra-sane-logging!
75
+
76
+ BUNDLED WITH
77
+ 1.13.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Tomek Wałkuski
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # sinatra-sane-logging
2
+
3
+ [![Code Climate](https://codeclimate.com/github/tomekw/sinatra-sane-logging/badges/gpa.svg)](https://codeclimate.com/github/tomekw/sinatra-sane-logging) [![Gem Version](https://badge.fury.io/rb/sinatra-sane-logging.svg)](https://badge.fury.io/rb/sinatra-sane-logging) [![CircleCI](https://circleci.com/gh/tomekw/sinatra-sane-logging.svg?style=svg)](https://circleci.com/gh/tomekw/sinatra-sane-logging)
4
+
5
+ Sinatra logging for human beings.
6
+
7
+ It allows to set both Rack, error and application logger.
8
+
9
+ It uses `Rack::Commonlogger` under the hood so the logger has to respond to:
10
+
11
+ * `<<(message)`
12
+ * `puts(message)`
13
+ * `flush`
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem "sinatra-sane-logging"
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install sinatra-sane-logging
30
+
31
+ ## Usage
32
+
33
+ ```ruby
34
+ require "logger"
35
+ require "sinatra/base"
36
+ require "sinatra/sane_logging"
37
+
38
+ class FileLogger < Logger
39
+ def flush; end
40
+ end
41
+
42
+ class App < Sinatra::Base
43
+ include Sinatra::SaneLogging
44
+
45
+ sane_logging logger: Filelogger.new(File.open("log/app.log", "a+").tap { |log_file| log_file.sync = true })
46
+
47
+ get "/" do
48
+ logger.info "OK"
49
+
50
+ "OK"
51
+ end
52
+ end
53
+ ```
54
+
55
+ ## Development
56
+
57
+ Build the Docker image:
58
+
59
+ $ docker-compose build
60
+
61
+ Create services:
62
+
63
+ $ docker-compose create
64
+
65
+ Run specs:
66
+
67
+ $ docker-compose run --rm app rspec spec
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tomekw/sinatra-sane-logging. 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.
72
+
73
+ ## License
74
+
75
+ 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,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
4
+
5
+ load "lib/tasks/ci.rake"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new(:rubocop)
9
+
10
+ task default: :spec
data/circle.yml ADDED
@@ -0,0 +1,12 @@
1
+ machine:
2
+ services:
3
+ - docker
4
+
5
+ dependencies:
6
+ override:
7
+ - docker build --rm=false -t tomekw/sinatra-sane-logging .
8
+
9
+ test:
10
+ override:
11
+ - docker run --rm tomekw/sinatra-sane-logging rubocop
12
+ - docker run --rm tomekw/sinatra-sane-logging rspec spec
@@ -0,0 +1,10 @@
1
+ version: "2"
2
+ services:
3
+ app:
4
+ build: .
5
+ environment:
6
+ JRUBY_OPTS: --debug
7
+ volumes:
8
+ - .:/sinatra-sane-logging
9
+ - ${HOME}/.ssh:/root/.ssh:ro
10
+ - ${HOME}/.gem:/root/.gem:rw
data/lib/sinatra.rb ADDED
@@ -0,0 +1,2 @@
1
+ module Sinatra
2
+ end
@@ -0,0 +1,20 @@
1
+ module Sinatra
2
+ module SaneLogging
3
+ def self.included(base)
4
+ base.send(:extend, ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def sane_logging(logger:)
9
+ configure do
10
+ use Rack::CommonLogger, logger
11
+ end
12
+
13
+ before do
14
+ env["rack.errors"] = logger
15
+ env["rack.logger"] = logger
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/tasks/ci.rake ADDED
@@ -0,0 +1,8 @@
1
+ require "rubocop/rake_task"
2
+
3
+ namespace :ci do
4
+ RuboCop::RakeTask.new(:rubocop)
5
+
6
+ desc "Run all CI checks"
7
+ task run: %i[rubocop spec]
8
+ end
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "sinatra-sane-logging"
6
+ spec.version = "0.1.0"
7
+ spec.authors = ["Tomek Wałkuski"]
8
+ spec.email = "ja@jestem.tw"
9
+
10
+ spec.summary = "Sinatra logging for human beings"
11
+ spec.homepage = "https://github.com/tomekw/sinatra-sane-logging"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+ spec.require_paths = %w[lib]
18
+
19
+ spec.add_dependency "sinatra", ">= 0"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.13"
22
+ spec.add_development_dependency "pry", ">= 0"
23
+ spec.add_development_dependency "rack-test", ">= 0"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "rspec", "~> 3.5"
26
+ spec.add_development_dependency "rubocop", "~> 0"
27
+ spec.add_development_dependency "simplecov", "~> 0"
28
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-sane-logging
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomek Wałkuski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
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: rack-test
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: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '12.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '12.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
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'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email: ja@jestem.tw
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - ".gitignore"
132
+ - ".rspec"
133
+ - ".rubocop.yml"
134
+ - CHANGELOG.md
135
+ - CODE_OF_CONDUCT.md
136
+ - Dockerfile
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - circle.yml
143
+ - docker-compose.yml
144
+ - lib/sinatra.rb
145
+ - lib/sinatra/sane_logging.rb
146
+ - lib/tasks/ci.rake
147
+ - sinatra-sane-logging.gemspec
148
+ homepage: https://github.com/tomekw/sinatra-sane-logging
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.6.8
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Sinatra logging for human beings
172
+ test_files: []