Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ignoreAssets. Rebuilt package-lock.json. #132

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

# [v5.3.3](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v5.3.2...v5.3.3) (2024-04-29)
### Features

* Added `ignoreAssets` option to the request logger. Should cut down noise a bit.
* Re-installed dependencies to do a package-lock reset. Should fix issues reported by Snyk.

# [v5.3.2](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v5.3.1...v5.3.2) (2024-04-22)
### Features

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ overridden in the `config/local.js`, just like every other option. If the option
<br /><br />See <a href="#request-logging">Request Logging</a> for more info.
</td>
</tr>
<tr>
<td><code>log.ignoreAssets</code></td>
<td><a href="config/log.js"><code>log.js</code></a></td>
<td><code>true</code></td>
<td>
When enabled (and `captureRequests` is `true`), this will force the logger to skip over assets (things like `.js` / `.css`, etc.).
</td>
</tr>
<tr>
<td><code>models.validateOnBootstrap</code></td>
<td><a href="config/models.js"><code>models.js</code></a></td>
Expand Down
2 changes: 1 addition & 1 deletion api/helpers/finalize-request-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
},

fn: async (inputs, exits) => {
if (inputs.req.id && sails.config.log.captureRequests === true) {
if (inputs.req.id && inputs.req.id !== 'IGNORE' && sails.config.log.captureRequests === true) {
const bleep = '*******';
let out = _.merge({}, inputs.body),
headers = _.merge({}, inputs.res.getHeaders()); // copy the object
Expand Down
14 changes: 13 additions & 1 deletion api/hooks/request-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ module.exports = (sails) => {
routes: {
before: {
'*': function(req, res, next) {
if (req.method !== 'HEAD' && req.path !== '/__getcookie' && req.path !== '/' && sails.config.log.captureRequests === true) {
if (
req.method !== 'HEAD'
&& req.path !== '/__getcookie'
&& req.path !== '/_ping'
&& req.path !== '/'
&& sails.config.log.captureRequests === true
) {
if (sails.config.log.ignoreAssets && req.path.includes('.')) {
req.id = 'IGNORE';

return next();
}

const bleep = '*******';

let body = _.merge({}, req.body),
Expand Down
10 changes: 9 additions & 1 deletion config/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,13 @@ module.exports.log = {
* *
********************************************************************/

captureRequests: true
captureRequests: true,

/********************************************************************
* This will ignore logging of asset requests *
* (things like `.js`, `.css`, etc.), when capturing request data. *
* *
* Turning this off could make request logs balloon very quickly. *
********************************************************************/
ignoreAssets: true
};
Loading
Loading