Skip to content

Commit 53386a4

Browse files
authored
Merge pull request #107 from neonexus/master
Added request logger config. README updates. Updated deps.
2 parents 1364cf2 + 822b52e commit 53386a4

File tree

8 files changed

+1897
-1326
lines changed

8 files changed

+1897
-1326
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Changelog
2+
## [v4.2.2](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.2.1...v4.2.2) (2023-09-13)
3+
### Features
4+
5+
* Added in a new configuration to enable/disable automatic request logging.
6+
*
7+
* Updated dependencies.
8+
29
## [v4.2.1](https://github.com/neonexus/sails-react-bootstrap-webpack/compare/v4.2.0...v4.2.1) (2023-04-23)
310
### Features
411

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18.16
1+
FROM node:18.17
22
MAINTAINER NeoNexus DeMortis
33

44
RUN mkdir /var/www && mkdir /var/www/myapp

README.md

+78-41
Large diffs are not rendered by default.

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) {
43+
if (inputs.req.id && 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

+1-10
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,14 @@ const stringify = require('json-stringify-safe');
22

33
module.exports = (sails) => {
44
return {
5-
65
initialize: function(cb) {
7-
// Assign this hook object to the `hook` var.
8-
// This allows us to add/modify values that users of the hook can retrieve.
9-
//hook = this;
10-
// Initialize a couple of values on the hook.
11-
//hook.numRequestsSeen = 0;
12-
//hook.numUnhandledRequestsSeen = 0;
13-
// Signal that initialization of this hook is complete
14-
// by calling the callback.
156
return cb();
167
},
178

189
routes: {
1910
before: {
2011
'*': function(req, res, next) {
21-
if (req.method !== 'HEAD' && req.path !== '/__getcookie' && req.path !== '/') {
12+
if (req.method !== 'HEAD' && req.path !== '/__getcookie' && req.path !== '/' && sails.config.log.captureRequests === true) {
2213
const bleep = '*******';
2314

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

config/log.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ module.exports.log = {
2424
* *
2525
***************************************************************************/
2626

27-
// level: 'info'
27+
level: 'info',
2828

29+
30+
/********************************************************************
31+
* *
32+
* This is a custom configuration option, for the request logger *
33+
* hook (api/hook/request-logger.js) and the finalize request log *
34+
* helper (api/helpers/finalize-request-log.js). *
35+
* *
36+
* When enabled, the hook and helper will automatically log all *
37+
* incoming requests using the RequestLog model. *
38+
* *
39+
********************************************************************/
40+
41+
captureRequests: true
2942
};

0 commit comments

Comments
 (0)