grape_logging 1.8.4 → 2.0.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 +4 -4
- data/.github/workflows/ci.yml +23 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +194 -0
- data/CONTRIBUTING.md +110 -0
- data/README.md +14 -13
- data/RELEASING.md +111 -0
- data/Rakefile +33 -0
- data/bin/console +0 -0
- data/grape_logging.gemspec +2 -5
- data/lib/grape_logging/loggers/filter_parameters.rb +17 -1
- data/lib/grape_logging/loggers/response.rb +1 -1
- data/lib/grape_logging/middleware/request_logger.rb +11 -13
- data/lib/grape_logging/reporters/logger_reporter.rb +1 -1
- data/lib/grape_logging/version.rb +1 -1
- metadata +13 -41
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f20fda586594dbf4f4ad0d0894476b53750f56d37c34df2b3ceb0b804ca27b1
|
4
|
+
data.tar.gz: 8550ca9bb7a492b7bd08eb9da98bd14f4d71af6052f2258b8861d6b9e6a068b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e58d85e6661ed164a4cf5f2e0675ace15fa6a224372fab1f8e07a27996a91fe078009a9d84b6cc6dbedcda2e357577b39cb9d298f5c20c1c3ec5a1e86da51e21
|
7
|
+
data.tar.gz: 0c8cd020637b865f1165b36072dfa6d22312528afbbb84f18157f80d6c960321e214d3475879cca583a175b646dcfc3b806cd53adbbd26915abafa4f9acdf9c0
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [master]
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: ["3.0", "3.1", "3.2", "3.3", "3.4"]
|
13
|
+
steps:
|
14
|
+
- name: Checkout code
|
15
|
+
uses: actions/checkout@v4
|
16
|
+
- uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby-version }}
|
19
|
+
bundler-cache: true
|
20
|
+
- name: Install dependencies
|
21
|
+
run: bundle install
|
22
|
+
- name: Run tests
|
23
|
+
run: bundle exec rspec spec/
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [2.0.0] - 2025-06-28
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
- **BREAKING**: Updated to support Grape 2.1 and Rack 3.1
|
7
|
+
- Minimum supported Ruby version is now 3.0
|
8
|
+
- Replaced Travis CI with GitHub Actions for continuous integration
|
9
|
+
- Updated all README examples to use `insert_before` instead of `use` for proper middleware placement
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- Fixed LoggerReporter to clone the logger parameter to prevent shared state issues (#77)
|
13
|
+
- Fixed view time precision issue by rounding to 2 decimal places
|
14
|
+
- Fixed invalid byte sequence handling for parameter keys by properly managing string encodings (#54)
|
15
|
+
- Fixed various typos in code comments and spec descriptions (#87)
|
16
|
+
- Fixed specs to work with Ruby 3.4's hash inspect format changes
|
17
|
+
|
18
|
+
### Documentation
|
19
|
+
- Clarified middleware placement requirements in README - must be inserted before Grape::Middleware::Error (#74)
|
20
|
+
- Added gem version badge to README
|
21
|
+
|
22
|
+
[2.0.0]: https://github.com/aserafin/grape_logging/compare/v1.8.4...v2.0.0
|
23
|
+
|
24
|
+
## [1.8.4] - 2021-10-29
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
- Rails 6 compatibility improvements
|
28
|
+
- Various bug fixes and dependency updates
|
29
|
+
|
30
|
+
[1.8.4]: https://github.com/aserafin/grape_logging/compare/v1.8.3...v1.8.4
|
31
|
+
|
32
|
+
## [1.8.3] - 2020-02-27
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
- Performance improvements
|
36
|
+
- Bug fixes for edge cases
|
37
|
+
|
38
|
+
[1.8.3]: https://github.com/aserafin/grape_logging/compare/v1.8.2...v1.8.3
|
39
|
+
|
40
|
+
## [1.8.2] - 2019-10-08
|
41
|
+
|
42
|
+
### Fixed
|
43
|
+
- Thread safety improvements
|
44
|
+
- Minor bug fixes
|
45
|
+
|
46
|
+
Note: This version was tagged as "v.1.8.2" (with extra dot)
|
47
|
+
|
48
|
+
[1.8.2]: https://github.com/aserafin/grape_logging/compare/v1.8.1...v.1.8.2
|
49
|
+
|
50
|
+
## [1.8.1] - 2019-08-07
|
51
|
+
|
52
|
+
### Fixed
|
53
|
+
- Bug fixes for parameter filtering
|
54
|
+
- Improved error handling
|
55
|
+
|
56
|
+
[1.8.1]: https://github.com/aserafin/grape_logging/compare/v1.8.0...v1.8.1
|
57
|
+
|
58
|
+
## [1.8.0] - 2019-05-30
|
59
|
+
|
60
|
+
### Added
|
61
|
+
- Rails formatter for better Rails integration
|
62
|
+
- Improved Rails instrumentation support
|
63
|
+
|
64
|
+
[1.8.0]: https://github.com/aserafin/grape_logging/compare/v1.7.0...v1.8.0
|
65
|
+
|
66
|
+
## [1.7.0] - 2017-11-09
|
67
|
+
|
68
|
+
### Added
|
69
|
+
- Logstash formatter for ELK stack integration
|
70
|
+
- Enhanced JSON formatting options
|
71
|
+
|
72
|
+
[1.7.0]: https://github.com/aserafin/grape_logging/compare/v1.6.0...v1.7.0
|
73
|
+
|
74
|
+
## [1.6.0] - 2017-07-20
|
75
|
+
|
76
|
+
### Added
|
77
|
+
- MultiIO support for logging to multiple destinations simultaneously
|
78
|
+
- Can now log to both file and STDOUT
|
79
|
+
|
80
|
+
[1.6.0]: https://github.com/aserafin/grape_logging/compare/v1.5.0...v1.6.0
|
81
|
+
|
82
|
+
## [1.5.0] - 2017-06-15
|
83
|
+
|
84
|
+
### Added
|
85
|
+
- Configurable log levels
|
86
|
+
- Better control over logging verbosity
|
87
|
+
|
88
|
+
[1.5.0]: https://github.com/aserafin/grape_logging/compare/v1.4.0...v1.5.0
|
89
|
+
|
90
|
+
## [1.4.0] - 2017-01-12
|
91
|
+
|
92
|
+
### Added
|
93
|
+
- FilterParameters logger for sensitive parameter filtering
|
94
|
+
- Automatic Rails filter_parameters integration when available
|
95
|
+
|
96
|
+
[1.4.0]: https://github.com/aserafin/grape_logging/compare/v1.3.0...v1.4.0
|
97
|
+
|
98
|
+
## [1.3.0] - 2016-12-08
|
99
|
+
|
100
|
+
### Added
|
101
|
+
- RequestHeaders logger for logging HTTP request headers
|
102
|
+
- ClientEnv logger for logging client IP and user agent
|
103
|
+
|
104
|
+
[1.3.0]: https://github.com/aserafin/grape_logging/compare/v1.2.1...v1.3.0
|
105
|
+
|
106
|
+
## [1.2.1] - 2016-04-14
|
107
|
+
|
108
|
+
### Added
|
109
|
+
- JSON formatter for structured logging
|
110
|
+
- Rails instrumentation support via ActiveSupport::Notifications
|
111
|
+
|
112
|
+
### Fixed
|
113
|
+
- Parameter handling improvements
|
114
|
+
|
115
|
+
[1.2.1]: https://github.com/aserafin/grape_logging/compare/v1.2.0...v1.2.1
|
116
|
+
|
117
|
+
## [1.2.0] - 2016-01-21
|
118
|
+
|
119
|
+
### Added
|
120
|
+
- Response logger for logging response details
|
121
|
+
- Improved parameter logging
|
122
|
+
|
123
|
+
### Changed
|
124
|
+
- Better integration with Grape middleware stack
|
125
|
+
|
126
|
+
[1.2.0]: https://github.com/aserafin/grape_logging/compare/v1.1.3...v1.2.0
|
127
|
+
|
128
|
+
## [1.1.3] - 2015-12-03
|
129
|
+
|
130
|
+
### Fixed
|
131
|
+
- Bug fixes for Grape 0.14 compatibility
|
132
|
+
- Improved error handling
|
133
|
+
|
134
|
+
[1.1.3]: https://github.com/aserafin/grape_logging/compare/v1.1.2...v1.1.3
|
135
|
+
|
136
|
+
## [1.1.2] - 2015-11-19
|
137
|
+
|
138
|
+
### Fixed
|
139
|
+
- Performance optimizations
|
140
|
+
- Minor bug fixes
|
141
|
+
|
142
|
+
[1.1.2]: https://github.com/aserafin/grape_logging/compare/v1.1.1...v1.1.2
|
143
|
+
|
144
|
+
## [1.1.1] - 2015-11-12
|
145
|
+
|
146
|
+
### Fixed
|
147
|
+
- Critical bug fix for middleware initialization
|
148
|
+
|
149
|
+
Note: This version was tagged as "v.1.1.1" (with extra dot)
|
150
|
+
|
151
|
+
[1.1.1]: https://github.com/aserafin/grape_logging/compare/v1.1.0...v.1.1.1
|
152
|
+
|
153
|
+
## [1.1.0] - 2015-11-09
|
154
|
+
|
155
|
+
### Added
|
156
|
+
- Pluggable logger architecture
|
157
|
+
- Support for custom loggers via include option
|
158
|
+
- Base logger class for extending functionality
|
159
|
+
|
160
|
+
### Changed
|
161
|
+
- Refactored middleware for better extensibility
|
162
|
+
|
163
|
+
[1.1.0]: https://github.com/aserafin/grape_logging/compare/v1.0.3...v1.1.0
|
164
|
+
|
165
|
+
## [1.0.3] - 2015-11-05
|
166
|
+
|
167
|
+
### Fixed
|
168
|
+
- Compatibility fixes for different Grape versions
|
169
|
+
- Bug fixes
|
170
|
+
|
171
|
+
[1.0.3]: https://github.com/aserafin/grape_logging/compare/v1.0.2...v1.0.3
|
172
|
+
|
173
|
+
## [1.0.2] - 2015-10-29
|
174
|
+
|
175
|
+
### Fixed
|
176
|
+
- Minor bug fixes and improvements
|
177
|
+
|
178
|
+
[1.0.2]: https://github.com/aserafin/grape_logging/compare/v1.0.1...v1.0.2
|
179
|
+
|
180
|
+
## [1.0.1] - 2015-10-22
|
181
|
+
|
182
|
+
### Fixed
|
183
|
+
- Initial bug fixes after 1.0 release
|
184
|
+
|
185
|
+
[1.0.1]: https://github.com/aserafin/grape_logging/compare/v1.0...v1.0.1
|
186
|
+
|
187
|
+
## [1.0] - 2015-10-15
|
188
|
+
|
189
|
+
### Added
|
190
|
+
- Initial release
|
191
|
+
- Request logging middleware for Grape APIs
|
192
|
+
- Basic request/response logging
|
193
|
+
- Configurable formatters
|
194
|
+
- Time tracking (total, db, view)
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# Contributing to grape_logging
|
2
|
+
|
3
|
+
This project is work of many contributors. You're encouraged to submit pull requests, propose features and discuss issues.
|
4
|
+
|
5
|
+
## Fork the Project
|
6
|
+
|
7
|
+
Fork the project on Github and check out your copy.
|
8
|
+
|
9
|
+
```
|
10
|
+
git clone https://github.com/contributor/grape_logging.git
|
11
|
+
cd grape_logging
|
12
|
+
git remote add upstream https://github.com/aserafin/grape_logging.git
|
13
|
+
```
|
14
|
+
|
15
|
+
## Create a Topic Branch
|
16
|
+
|
17
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
18
|
+
|
19
|
+
```
|
20
|
+
git checkout master
|
21
|
+
git pull upstream master
|
22
|
+
git checkout -b my-feature-branch
|
23
|
+
```
|
24
|
+
|
25
|
+
## Bundle Install and Test
|
26
|
+
|
27
|
+
Ensure that you can build the project and run tests.
|
28
|
+
|
29
|
+
```
|
30
|
+
bundle install
|
31
|
+
bundle exec rake
|
32
|
+
```
|
33
|
+
|
34
|
+
## Write Tests
|
35
|
+
|
36
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to the spec directory.
|
37
|
+
|
38
|
+
## Write Code
|
39
|
+
|
40
|
+
Implement your feature or bug fix.
|
41
|
+
|
42
|
+
Ruby style is enforced with RuboCop. Run `bundle exec rubocop` and fix any style issues highlighted.
|
43
|
+
|
44
|
+
Make sure that `bundle exec rake` completes without errors.
|
45
|
+
|
46
|
+
## Write Documentation
|
47
|
+
|
48
|
+
Document any external behavior in the README.md.
|
49
|
+
|
50
|
+
## Update Changelog
|
51
|
+
|
52
|
+
Add a line to Changelog.md under *Next Release*. Make it look like every other line, including your name and link to your Github account.
|
53
|
+
|
54
|
+
## Commit Changes
|
55
|
+
|
56
|
+
Make sure git knows your name and email address:
|
57
|
+
|
58
|
+
```
|
59
|
+
git config --global user.name "Your Name"
|
60
|
+
git config --global user.email "contributor@example.com"
|
61
|
+
```
|
62
|
+
|
63
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
64
|
+
|
65
|
+
```
|
66
|
+
git add ...
|
67
|
+
git commit
|
68
|
+
```
|
69
|
+
|
70
|
+
## Push
|
71
|
+
|
72
|
+
```
|
73
|
+
git push origin my-feature-branch
|
74
|
+
```
|
75
|
+
|
76
|
+
## Make a Pull Request
|
77
|
+
|
78
|
+
Go to https://github.com/contributor/grape_logging and select your feature branch. Click the 'Pull Request' button and fill out the form.
|
79
|
+
|
80
|
+
We'll try to review pull requests within a few days but as this is maintained by a small group of volunteers there is no guarantee that we'll look at it within any time frame, or at all. There's no maintenance guarantee.
|
81
|
+
|
82
|
+
## Discuss and Update
|
83
|
+
|
84
|
+
You may get feedback or requests for changes to your pull request. This is a big part of the submission process so don't be discouraged!
|
85
|
+
|
86
|
+
Some things that will increase the chance that your pull request is accepted:
|
87
|
+
|
88
|
+
- Write tests.
|
89
|
+
- Follow the Ruby style guide.
|
90
|
+
- Write a good commit message.
|
91
|
+
|
92
|
+
If you'd like to discuss a feature or bug fix before starting work, please [create an issue](https://github.com/aserafin/grape_logging/issues) first. This helps ensure your contribution aligns with the project's direction and avoids duplicate efforts.
|
93
|
+
|
94
|
+
## Rebase
|
95
|
+
|
96
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
97
|
+
|
98
|
+
```
|
99
|
+
git fetch upstream
|
100
|
+
git rebase upstream/master
|
101
|
+
git push origin my-feature-branch -f
|
102
|
+
```
|
103
|
+
|
104
|
+
## Be Patient
|
105
|
+
|
106
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there!
|
107
|
+
|
108
|
+
## Thank You
|
109
|
+
|
110
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# grape_logging
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/grape_logging)
|
4
|
+
[](https://github.com/aserafin/grape_logging/actions/workflows/ci.yml)
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -19,12 +19,12 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
## Basic Usage
|
21
21
|
|
22
|
-
In your
|
22
|
+
In your API file (somewhere on the top), insert grape logging middleware before grape error middleware. This is important due to the behaviour of `lib/grape/middleware/error.rb`, which manipulates the status of the response when there is an error.
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
require 'grape_logging'
|
26
26
|
logger.formatter = GrapeLogging::Formatters::Default.new
|
27
|
-
|
27
|
+
insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, { logger: logger }
|
28
28
|
```
|
29
29
|
|
30
30
|
**ProTip:** If your logger doesn't support setting formatter you can remove this line - it's optional
|
@@ -114,7 +114,7 @@ end
|
|
114
114
|
You can change the formatter like so
|
115
115
|
```ruby
|
116
116
|
class MyAPI < Grape::API
|
117
|
-
|
117
|
+
insert_before Grape::Middleware::Error, GrapeLogging::Middleware::RequestLogger, logger: logger, formatter: MyFormatter.new
|
118
118
|
end
|
119
119
|
```
|
120
120
|
|
@@ -125,7 +125,8 @@ If you prefer some other format I strongly encourage you to do pull request with
|
|
125
125
|
You can include logging of other parts of the request / response cycle by including subclasses of `GrapeLogging::Loggers::Base`
|
126
126
|
```ruby
|
127
127
|
class MyAPI < Grape::API
|
128
|
-
|
128
|
+
insert_before Grape::Middleware::Error,
|
129
|
+
GrapeLogging::Middleware::RequestLogger,
|
129
130
|
logger: logger,
|
130
131
|
include: [ GrapeLogging::Loggers::Response.new,
|
131
132
|
GrapeLogging::Loggers::FilterParameters.new,
|
@@ -158,7 +159,8 @@ You can control the level used to log. The default is `info`.
|
|
158
159
|
|
159
160
|
```ruby
|
160
161
|
class MyAPI < Grape::API
|
161
|
-
|
162
|
+
insert_before Grape::Middleware::Error,
|
163
|
+
GrapeLogging::Middleware::RequestLogger,
|
162
164
|
logger: logger,
|
163
165
|
log_level: 'debug'
|
164
166
|
end
|
@@ -170,7 +172,8 @@ You can choose to not pass the logger to ```grape_logging``` but instead send lo
|
|
170
172
|
First, config ```grape_logging```, like that:
|
171
173
|
```ruby
|
172
174
|
class MyAPI < Grape::API
|
173
|
-
|
175
|
+
insert_before Grape::Middleware::Error,
|
176
|
+
GrapeLogging::Middleware::RequestLogger,
|
174
177
|
instrumentation_key: 'grape_key',
|
175
178
|
include: [ GrapeLogging::Loggers::Response.new,
|
176
179
|
GrapeLogging::Loggers::FilterParameters.new ]
|
@@ -206,10 +209,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
206
209
|
|
207
210
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
208
211
|
|
212
|
+
For maintainers releasing a new version, please see [Releasing.md](Releasing.md).
|
213
|
+
|
209
214
|
## Contributing
|
210
215
|
|
211
|
-
|
212
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
213
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
214
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
215
|
-
5. Create a new Pull Request
|
216
|
+
See [Contributing.md](Contributing.md).
|
data/RELEASING.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# Releasing grape_logging
|
2
|
+
|
3
|
+
There're no particular rules about when to release grape_logging. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
|
4
|
+
|
5
|
+
### Pre-flight Checks
|
6
|
+
|
7
|
+
Run tests, check that all tests succeed locally.
|
8
|
+
|
9
|
+
```
|
10
|
+
bundle install
|
11
|
+
rake
|
12
|
+
```
|
13
|
+
|
14
|
+
Check that the last build succeeded in [GitHub Actions](https://github.com/aserafin/grape_logging/actions) for all supported platforms.
|
15
|
+
|
16
|
+
### Update Changelog
|
17
|
+
|
18
|
+
Change "Next Release" in [CHANGELOG.md](https://github.com/aserafin/grape_logging/blob/master/CHANGELOG.md) to the new version and date:
|
19
|
+
|
20
|
+
```
|
21
|
+
## [1.8.5] - 2024-06-28
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
- Description of changes
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
- Description of fixes
|
28
|
+
|
29
|
+
### Added
|
30
|
+
- Description of additions
|
31
|
+
|
32
|
+
[1.8.5]: https://github.com/aserafin/grape_logging/compare/v1.8.4...v1.8.5
|
33
|
+
```
|
34
|
+
|
35
|
+
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
36
|
+
|
37
|
+
Only include the sections (Changed, Fixed, Added, etc.) that have actual changes.
|
38
|
+
|
39
|
+
Commit your changes.
|
40
|
+
|
41
|
+
```shell
|
42
|
+
git add CHANGELOG.md lib/grape_logging/version.rb
|
43
|
+
git commit -m "Preparing for release, 1.8.5."
|
44
|
+
git push github master
|
45
|
+
```
|
46
|
+
|
47
|
+
### Release on RubyGems and GitHub
|
48
|
+
|
49
|
+
#### Option 1: Automated (Recommended)
|
50
|
+
|
51
|
+
Use the combined task that releases the gem and creates a GitHub release:
|
52
|
+
|
53
|
+
```shell
|
54
|
+
rake github_release
|
55
|
+
```
|
56
|
+
|
57
|
+
This will:
|
58
|
+
1. Build and push the gem to RubyGems
|
59
|
+
2. Create and push the git tag
|
60
|
+
3. Create a GitHub release with auto-generated changelog
|
61
|
+
|
62
|
+
#### Option 2: Manual
|
63
|
+
|
64
|
+
First, release the gem:
|
65
|
+
|
66
|
+
```shell
|
67
|
+
rake release
|
68
|
+
```
|
69
|
+
|
70
|
+
Output will look something like:
|
71
|
+
```
|
72
|
+
grape_logging 1.8.5 built to pkg/grape_logging-1.8.5.gem.
|
73
|
+
Tagged v1.8.5.
|
74
|
+
Pushed git commits and tags.
|
75
|
+
Pushed grape_logging 1.8.5 to rubygems.org.
|
76
|
+
```
|
77
|
+
|
78
|
+
Then create the GitHub release on the web or using `gh`:
|
79
|
+
|
80
|
+
```
|
81
|
+
gh release create v1.8.5 --generate-notes --verify-tag
|
82
|
+
```
|
83
|
+
|
84
|
+
This uses GitHub's automatic changelog generation feature to create release notes from merged pull requests and commits since the last release.
|
85
|
+
|
86
|
+
### Prepare for the Next Version
|
87
|
+
|
88
|
+
Modify `lib/grape_logging/version.rb`, increment the version number (eg. change `1.8.5` to `1.8.6`).
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
module GrapeLogging
|
92
|
+
VERSION = '1.8.6'.freeze
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
Add the next release to [CHANGELOG.md](https://github.com/aserafin/grape_logging/blob/master/CHANGELOG.md).
|
97
|
+
|
98
|
+
```
|
99
|
+
## [Next Release]
|
100
|
+
|
101
|
+
### Changed or Fixed or Added
|
102
|
+
* Your contribution here.
|
103
|
+
```
|
104
|
+
|
105
|
+
Commit your changes.
|
106
|
+
|
107
|
+
```
|
108
|
+
git add CHANGELOG.md lib/grape_logging/version.rb
|
109
|
+
git commit -m "Bump version to 1.8.6."
|
110
|
+
git push github master
|
111
|
+
```
|
data/Rakefile
CHANGED
@@ -1,2 +1,35 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
2
3
|
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task default: :spec
|
7
|
+
|
8
|
+
desc 'Release gem and create GitHub release'
|
9
|
+
task github_release: :release do
|
10
|
+
require 'grape_logging/version'
|
11
|
+
|
12
|
+
version = "v#{GrapeLogging::VERSION}"
|
13
|
+
|
14
|
+
# Check if gh CLI is available
|
15
|
+
unless system('which gh > /dev/null 2>&1')
|
16
|
+
puts "\n⚠️ GitHub CLI (gh) not found"
|
17
|
+
puts "To create a GitHub release with auto-generated changelog, install gh:"
|
18
|
+
puts " brew install gh # macOS with Homebrew"
|
19
|
+
puts " # or visit: https://github.com/cli/cli#installation"
|
20
|
+
puts "\nYou can manually create the release with:"
|
21
|
+
puts " gh release create v#{GrapeLogging::VERSION} --generate-notes"
|
22
|
+
next
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create GitHub release
|
26
|
+
puts "\nCreating GitHub release #{version}..."
|
27
|
+
|
28
|
+
if system('gh', 'release', 'create', version, '--generate-notes', '--verify-tag')
|
29
|
+
puts "✅ GitHub release #{version} created successfully"
|
30
|
+
else
|
31
|
+
puts "❌ Failed to create GitHub release"
|
32
|
+
puts "You can manually create it with:"
|
33
|
+
puts " gh release create '#{version}' --generate-notes --verify-tag"
|
34
|
+
end
|
35
|
+
end
|
data/bin/console
CHANGED
File without changes
|
data/grape_logging.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'grape_logging/version'
|
@@ -19,11 +18,9 @@ Gem::Specification.new do |spec|
|
|
19
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
19
|
spec.require_paths = ['lib']
|
21
20
|
|
22
|
-
spec.add_dependency 'grape'
|
21
|
+
spec.add_dependency 'grape', '< 2.4.0'
|
23
22
|
spec.add_dependency 'rack'
|
24
23
|
|
25
|
-
spec.add_development_dependency '
|
26
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rake', '~> 13.3'
|
27
25
|
spec.add_development_dependency 'rspec', '~> 3.5'
|
28
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.4.2'
|
29
26
|
end
|
@@ -29,7 +29,23 @@ module GrapeLogging
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def clean_parameters(parameters)
|
32
|
-
|
32
|
+
original_encoding_map = build_encoding_map(parameters)
|
33
|
+
params = transform_key_encoding(parameters, Hash.new{ |h, _| [Encoding::ASCII_8BIT, h] })
|
34
|
+
cleaned_params = parameter_filter.filter(params).reject{ |key, _value| @exceptions.include?(key) }
|
35
|
+
transform_key_encoding(cleaned_params, original_encoding_map)
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_encoding_map(parameters)
|
39
|
+
parameters.each_with_object({}) do |(k, v), h|
|
40
|
+
h[k.dup.force_encoding(Encoding::ASCII_8BIT)] = [k.encoding, v.is_a?(Hash) ? build_encoding_map(v) : nil]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def transform_key_encoding(parameters, encoding_map)
|
45
|
+
parameters.each_with_object({}) do |(k, v), h|
|
46
|
+
encoding, children_encoding_map = encoding_map[k]
|
47
|
+
h[k.dup.force_encoding(encoding)] = v.is_a?(Hash) ? transform_key_encoding(v, children_encoding_map) : v
|
48
|
+
end
|
33
49
|
end
|
34
50
|
end
|
35
51
|
end
|
@@ -9,7 +9,7 @@ module GrapeLogging
|
|
9
9
|
|
10
10
|
# In some cases, response.body is not parseable by JSON.
|
11
11
|
# For example, if you POST on a PUT endpoint, response.body is egal to """".
|
12
|
-
# It's strange but it's the Grape behavior...
|
12
|
+
# It's strange, but it's the Grape behavior...
|
13
13
|
def serialized_response_body(response)
|
14
14
|
|
15
15
|
if response.respond_to?(:body)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'grape
|
1
|
+
require 'grape'
|
2
2
|
|
3
3
|
module GrapeLogging
|
4
4
|
module Middleware
|
@@ -37,7 +37,7 @@ module GrapeLogging
|
|
37
37
|
@response_status = status
|
38
38
|
@response_body = response
|
39
39
|
|
40
|
-
# Perform
|
40
|
+
# Perform reporters
|
41
41
|
@reporter.perform(collect_parameters)
|
42
42
|
|
43
43
|
# Invoke loggers
|
@@ -56,20 +56,18 @@ module GrapeLogging
|
|
56
56
|
|
57
57
|
# Catch error
|
58
58
|
error = catch(:error) do
|
59
|
-
|
60
|
-
@app_response = @app.call(@env)
|
61
|
-
rescue => e
|
62
|
-
# Log as 500 + message
|
63
|
-
after(e.respond_to?(:status) ? e.status : 500, e.message)
|
64
|
-
|
65
|
-
# Re-raise exception
|
66
|
-
raise e
|
67
|
-
end
|
59
|
+
@app_response = @app.call(@env)
|
68
60
|
nil
|
61
|
+
rescue StandardError => e
|
62
|
+
# Log as 500 + message
|
63
|
+
after(e.respond_to?(:status) ? e.status : 500, e.message)
|
64
|
+
|
65
|
+
# Re-raise exception
|
66
|
+
raise e
|
69
67
|
end
|
70
68
|
|
71
69
|
# Get status & response from app_response
|
72
|
-
# when no error
|
70
|
+
# when no error occurs.
|
73
71
|
if error
|
74
72
|
# Call with error & response
|
75
73
|
after(error[:status], error[:message])
|
@@ -115,7 +113,7 @@ module GrapeLogging
|
|
115
113
|
end
|
116
114
|
|
117
115
|
def view_runtime
|
118
|
-
total_runtime - db_runtime
|
116
|
+
(total_runtime - db_runtime).round(2)
|
119
117
|
end
|
120
118
|
|
121
119
|
def db_runtime
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Reporters
|
2
2
|
class LoggerReporter
|
3
3
|
def initialize(logger, formatter, log_level)
|
4
|
-
@logger = logger || Logger.new(STDOUT)
|
4
|
+
@logger = logger.clone || Logger.new(STDOUT)
|
5
5
|
@log_level = log_level || :info
|
6
6
|
if @logger.respond_to?(:formatter=)
|
7
7
|
@logger.formatter = formatter || @logger.formatter || GrapeLogging::Formatters::Default.new
|
metadata
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aserafin
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: grape
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- - "
|
16
|
+
- - "<"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
18
|
+
version: 2.4.0
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
|
-
- - "
|
23
|
+
- - "<"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
25
|
+
version: 2.4.0
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rack
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,34 +37,20 @@ dependencies:
|
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bundler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.8'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.8'
|
55
40
|
- !ruby/object:Gem::Dependency
|
56
41
|
name: rake
|
57
42
|
requirement: !ruby/object:Gem::Requirement
|
58
43
|
requirements:
|
59
44
|
- - "~>"
|
60
45
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
46
|
+
version: '13.3'
|
62
47
|
type: :development
|
63
48
|
prerelease: false
|
64
49
|
version_requirements: !ruby/object:Gem::Requirement
|
65
50
|
requirements:
|
66
51
|
- - "~>"
|
67
52
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
53
|
+
version: '13.3'
|
69
54
|
- !ruby/object:Gem::Dependency
|
70
55
|
name: rspec
|
71
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +65,6 @@ dependencies:
|
|
80
65
|
- - "~>"
|
81
66
|
- !ruby/object:Gem::Version
|
82
67
|
version: '3.5'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry-byebug
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 3.4.2
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 3.4.2
|
97
68
|
description: This gem provides simple request logging for Grape with just few lines
|
98
69
|
of code you have to put in your project! In return you will get response codes,
|
99
70
|
paths, parameters and more!
|
@@ -103,11 +74,14 @@ executables: []
|
|
103
74
|
extensions: []
|
104
75
|
extra_rdoc_files: []
|
105
76
|
files:
|
77
|
+
- ".github/workflows/ci.yml"
|
106
78
|
- ".gitignore"
|
107
|
-
-
|
79
|
+
- CHANGELOG.md
|
80
|
+
- CONTRIBUTING.md
|
108
81
|
- Gemfile
|
109
82
|
- LICENSE.txt
|
110
83
|
- README.md
|
84
|
+
- RELEASING.md
|
111
85
|
- Rakefile
|
112
86
|
- bin/console
|
113
87
|
- bin/setup
|
@@ -134,7 +108,6 @@ homepage: http://github.com/aserafin/grape_logging
|
|
134
108
|
licenses:
|
135
109
|
- MIT
|
136
110
|
metadata: {}
|
137
|
-
post_install_message:
|
138
111
|
rdoc_options: []
|
139
112
|
require_paths:
|
140
113
|
- lib
|
@@ -149,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
122
|
- !ruby/object:Gem::Version
|
150
123
|
version: '0'
|
151
124
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
153
|
-
signing_key:
|
125
|
+
rubygems_version: 3.6.7
|
154
126
|
specification_version: 4
|
155
127
|
summary: Out of the box request logging for Grape!
|
156
128
|
test_files: []
|