Skip to content

Commit 93bda88

Browse files
authored
Merge pull request #890 from jurgenwerk/master
Allow disabling default logging in fastboot-app-server
2 parents 0f1dc96 + 083de34 commit 93bda88

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

packages/fastboot-app-server/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ let server = new FastBootAppServer({
4242
host: '0.0.0.0', // Optional - Sets the host the server listens on.
4343
port: 4000, // Optional - Sets the port the server listens on (defaults to the PORT env var or 3000).
4444
buildSandboxGlobals(defaultGlobals) { // Optional - Make values available to the Ember app running in the FastBoot server, e.g. "MY_GLOBAL" will be available as "GLOBAL_VALUE"
45+
log: true, // Optional - Specifies whether the server should use its default request logging. Useful for turning off default logging when providing custom logging middlewares
4546
return Object.assign({}, defaultGlobals, { GLOBAL_VALUE: MY_GLOBAL });
4647
},
4748
chunkedResponse: true // Optional - Opt-in to chunked transfer encoding, transferring the head, body and potential shoeboxes in separate chunks. Chunked transfer encoding should have a positive effect in particular when the app transfers a lot of data in the shoebox.
@@ -134,6 +135,26 @@ const server = FastBootAppServer({
134135
})
135136
```
136137

138+
## Logging
139+
140+
We provide simple log output by default, but if you want more logging control, you can disable the
141+
simple logger using the `log: false` option, and provide a custom middleware that suits your logging needs:
142+
143+
```js
144+
let server = new FastBootAppServer({
145+
log: false,
146+
beforeMiddleware: function(app) {
147+
let logger = function(req, res, next) {
148+
console.log('Hello from custom request logger');
149+
150+
next();
151+
};
152+
153+
app.use(logger);
154+
},
155+
});
156+
```
157+
137158
## Downloaders
138159

139160
You can point the app server at a static path that you manage, but that

packages/fastboot-app-server/src/fastboot-app-server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class FastBootAppServer {
2525
this.afterMiddleware = options.afterMiddleware;
2626
this.buildSandboxGlobals = options.buildSandboxGlobals;
2727
this.chunkedResponse = options.chunkedResponse;
28+
this.log = options.log;
2829

2930
if (!this.ui) {
3031
let UI = require('./ui');

packages/fastboot-app-server/src/worker.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Worker {
1919
this.afterMiddleware = options.afterMiddleware;
2020
this.buildSandboxGlobals = options.buildSandboxGlobals;
2121
this.chunkedResponse = options.chunkedResponse;
22+
this.log = options.log;
2223

2324
if (!this.httpServer) {
2425
this.httpServer = new ExpressHTTPServer({
@@ -80,6 +81,7 @@ class Worker {
8081
return fastbootMiddleware({
8182
fastboot: this.fastboot,
8283
chunkedResponse: this.chunkedResponse,
84+
log: this.log,
8385
});
8486
}
8587

0 commit comments

Comments
 (0)