Skip to content

Commit 50176cf

Browse files
authored
Merge pull request #132 from neonexus/master
Added `ignoreAssets`. Rebuilt package-lock.json.
2 parents 71eec86 + e9e7131 commit 50176cf

File tree

7 files changed

+1914
-1349
lines changed

7 files changed

+1914
-1349
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
# [v5.3.3](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v5.3.2...v5.3.3) (2024-04-29)
4+
### Features
5+
6+
* Added `ignoreAssets` option to the request logger. Should cut down noise a bit.
7+
* Re-installed dependencies to do a package-lock reset. Should fix issues reported by Snyk.
8+
39
# [v5.3.2](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v5.3.1...v5.3.2) (2024-04-22)
410
### Features
511

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ overridden in the `config/local.js`, just like every other option. If the option
225225
<br /><br />See <a href="#request-logging">Request Logging</a> for more info.
226226
</td>
227227
</tr>
228+
<tr>
229+
<td><code>log.ignoreAssets</code></td>
230+
<td><a href="config/log.js"><code>log.js</code></a></td>
231+
<td><code>true</code></td>
232+
<td>
233+
When enabled (and `captureRequests` is `true`), this will force the logger to skip over assets (things like `.js` / `.css`, etc.).
234+
</td>
235+
</tr>
228236
<tr>
229237
<td><code>models.validateOnBootstrap</code></td>
230238
<td><a href="config/models.js"><code>models.js</code></a></td>

api/helpers/finalize-request-log.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
},
4141

4242
fn: async (inputs, exits) => {
43-
if (inputs.req.id && sails.config.log.captureRequests === true) {
43+
if (inputs.req.id && inputs.req.id !== 'IGNORE' && sails.config.log.captureRequests === true) {
4444
const bleep = '*******';
4545
let out = _.merge({}, inputs.body),
4646
headers = _.merge({}, inputs.res.getHeaders()); // copy the object

api/hooks/request-logger.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ module.exports = (sails) => {
99
routes: {
1010
before: {
1111
'*': function(req, res, next) {
12-
if (req.method !== 'HEAD' && req.path !== '/__getcookie' && req.path !== '/' && sails.config.log.captureRequests === true) {
12+
if (
13+
req.method !== 'HEAD'
14+
&& req.path !== '/__getcookie'
15+
&& req.path !== '/_ping'
16+
&& req.path !== '/'
17+
&& sails.config.log.captureRequests === true
18+
) {
19+
if (sails.config.log.ignoreAssets && req.path.includes('.')) {
20+
req.id = 'IGNORE';
21+
22+
return next();
23+
}
24+
1325
const bleep = '*******';
1426

1527
let body = _.merge({}, req.body),

config/log.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,13 @@ module.exports.log = {
3838
* *
3939
********************************************************************/
4040

41-
captureRequests: true
41+
captureRequests: true,
42+
43+
/********************************************************************
44+
* This will ignore logging of asset requests *
45+
* (things like `.js`, `.css`, etc.), when capturing request data. *
46+
* *
47+
* Turning this off could make request logs balloon very quickly. *
48+
********************************************************************/
49+
ignoreAssets: true
4250
};

0 commit comments

Comments
 (0)