Skip to content

Commit 88b14fe

Browse files
committed
Ability to disable the ExpressJS request log lines
1 parent 6017446 commit 88b14fe

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ const sleep = promisify(setTimeout);
1212
app.set('json spaces', 2);
1313
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
1414

15-
app.use(morgan('combined'));
15+
if(process.env.DISABLE_REQUEST_LOGS !== 'true'){
16+
app.use(morgan('combined'));
17+
}
1618

1719
app.use(function(req, res, next){
1820
req.pipe(concat(function(data){

tests.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,23 @@ else
213213
fi
214214

215215

216+
message " Stop containers "
217+
docker stop http-echo-tests
218+
219+
message " Start container with DISABLE_REQUEST_LOGS "
220+
docker run -d --rm -e DISABLE_REQUEST_LOGS=true --name http-echo-tests -p 8080:8080 -p 8443:8443 -t mendhak/http-https-echo
221+
sleep 5
222+
curl -s -k -X GET https://localhost:8443/strawberry > /dev/null
223+
if [ $(docker logs http-echo-tests | grep -c "GET /strawberry HTTP/1.1") -eq 0 ]
224+
then
225+
passed "DISABLE_REQUEST_LOGS disabled Express HTTP logging"
226+
else
227+
failed "DISABLE_REQUEST_LOGS failed"
228+
docker logs http-echo-tests
229+
exit 1
230+
fi
231+
232+
216233
message " Stop containers "
217234
docker stop http-echo-tests
218235

0 commit comments

Comments
 (0)