W
Wasp-lang7mo ago
Karan

Turning off ASCII color logging in PROD

I have deployed my opensaas template on AWS App Runner and viewing the logs in CloudWatch is really ugly because ASCII Color logging is not supported. Can I turn off colored logging on PROD?
25 Replies
kapa.ai
kapa.ai7mo ago
Hi @Karan. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. The provided knowledge sources do not contain information on how to turn off ASCII color logging in the production environment for the OpenSaaS template on AWS App Runner. I recommend checking the official Wasp documentation or reaching out to the Wasp community for more specific guidance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Karan, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Karan
KaranOP7mo ago
Here is an example of log messages
[0mGET /auth/google/login 302 1.222 ms - -
[0mGET /auth/google/login 302 1.222 ms - -
Filip
Filip7mo ago
Hey @Karan, That's a good question (a general one too, not Wasp specific). The colors your seeing are decided by express which Wasp uses internally, so your question comes down to two separate questions: 1. How to disable colored output in an express server? - To answer this one, I can refer you to these two posts: Post 1, Post 2 2. How to configure the express server Wasp uses? - For this, you can use the server setup function and do an app.use(...) in there. See the docs for details.
Karan
KaranOP7mo ago
Thanks so much I will try these out! It's great to be able to configure express from wasp!
Filip
Filip7mo ago
Yeah, we need to have an escape hatch for all the stuff we don't do (yet!) Glad you like it!
Karan
KaranOP7mo ago
So I attempted this fix and ran into another issue during the docker build. 5.236 [!] RollupError: src/middleware/globalMiddleware.ts (11:9): "serverMiddlewareFn" is not exported by "../../../src/serverSetup.ts", imported by "src/middleware/globalMiddleware.ts". Here is my serverSetup.ts
import logger from 'morgan';
import { type MiddlewareConfigFn } from 'wasp/server';

const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig: any) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('logger', logger('combined'));
return middlewareConfig;
};

export default serverMiddlewareFn;
import logger from 'morgan';
import { type MiddlewareConfigFn } from 'wasp/server';

const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig: any) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('logger', logger('combined'));
return middlewareConfig;
};

export default serverMiddlewareFn;
Any idea whats going wrong here?
miho
miho7mo ago
Are you importing it like this in the Wasp file?
import { serverMiddlewareFn } from "@src/serverSetup"
import { serverMiddlewareFn } from "@src/serverSetup"
This is called a named import because you are importing a specific symbol i.e. serverMiddlewareFn You are using a default export in your file, which can only be imported like this:
import serverMiddlewareFn from "@src/serverSetup"
import serverMiddlewareFn from "@src/serverSetup"
Karan
KaranOP7mo ago
So I was using the named import but moved to your suggested import and still seeing the issue:
2.497 > [email protected] bundle
2.497 > rollup --config --silent
2.497
5.193 [!] RollupError: src/middleware/globalMiddleware.ts (11:9): "serverMiddlewareFn" is not exported by "../../../src/serverSetup.ts", imported by "src/middleware/globalMiddleware.ts".
5.193 https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
5.193 src/middleware/globalMiddleware.ts (11:9)
5.193 9: export type { MiddlewareConfig, MiddlewareConfigFn } from 'wasp/server/middleware'
5.193 10:
5.193 11: import { serverMiddlewareFn as _waspGlobalMiddlewareConfigFn } from '../../../../../src/serverSetup'
5.193 ^
5.193 12:
5.193 13: // This is the set of middleware Wasp supplies by default.
5.193 at getRollupError (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:282:41)
5.193 at Object.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:278:42)
5.193 at Module.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15290:28)
5.193 at Module.traceVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15738:29)
5.193 at ModuleScope.findVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:13426:39)
5.193 at Identifier.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:8362:40)
5.193 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.193 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:10577:15)
5.193 at VariableDeclarator.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.193 at VariableDeclaration.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6227:28)
2.497 > [email protected] bundle
2.497 > rollup --config --silent
2.497
5.193 [!] RollupError: src/middleware/globalMiddleware.ts (11:9): "serverMiddlewareFn" is not exported by "../../../src/serverSetup.ts", imported by "src/middleware/globalMiddleware.ts".
5.193 https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
5.193 src/middleware/globalMiddleware.ts (11:9)
5.193 9: export type { MiddlewareConfig, MiddlewareConfigFn } from 'wasp/server/middleware'
5.193 10:
5.193 11: import { serverMiddlewareFn as _waspGlobalMiddlewareConfigFn } from '../../../../../src/serverSetup'
5.193 ^
5.193 12:
5.193 13: // This is the set of middleware Wasp supplies by default.
5.193 at getRollupError (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:282:41)
5.193 at Object.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:278:42)
5.193 at Module.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15290:28)
5.193 at Module.traceVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15738:29)
5.193 at ModuleScope.findVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:13426:39)
5.193 at Identifier.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:8362:40)
5.193 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.193 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:10577:15)
5.193 at VariableDeclarator.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.193 at VariableDeclaration.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6227:28)
I even tried doing a named export instead of default export like this
import logger from 'morgan';
import { type MiddlewareConfigFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig: any) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('logger', logger('combined'));
return middlewareConfig;
};
import logger from 'morgan';
import { type MiddlewareConfigFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig: any) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('logger', logger('combined'));
return middlewareConfig;
};
and setup a named import like this
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
getting this output:
2.679 > rollup --config --silent
2.679
5.363 [!] RollupError: src/middleware/globalMiddleware.ts (11:9): "serverMiddlewareFn" is not exported by "../../../src/serverSetup.ts", imported by "src/middleware/globalMiddleware.ts".
5.363 https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
5.363 src/middleware/globalMiddleware.ts (11:9)
5.363 9: export type { MiddlewareConfig, MiddlewareConfigFn } from 'wasp/server/middleware'
5.363 10:
5.363 11: import { serverMiddlewareFn as _waspGlobalMiddlewareConfigFn } from '../../../../../src/serverSetup'
5.363 ^
5.363 12:
5.363 13: // This is the set of middleware Wasp supplies by default.
5.363 at getRollupError (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:282:41)
5.363 at Object.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:278:42)
5.363 at Module.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15290:28)
5.363 at Module.traceVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15738:29)
5.363 at ModuleScope.findVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:13426:39)
5.363 at Identifier.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:8362:40)
5.363 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.363 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:10577:15)
5.363 at VariableDeclarator.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.363 at VariableDeclaration.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6227:28)
5.363
5.363
2.679 > rollup --config --silent
2.679
5.363 [!] RollupError: src/middleware/globalMiddleware.ts (11:9): "serverMiddlewareFn" is not exported by "../../../src/serverSetup.ts", imported by "src/middleware/globalMiddleware.ts".
5.363 https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
5.363 src/middleware/globalMiddleware.ts (11:9)
5.363 9: export type { MiddlewareConfig, MiddlewareConfigFn } from 'wasp/server/middleware'
5.363 10:
5.363 11: import { serverMiddlewareFn as _waspGlobalMiddlewareConfigFn } from '../../../../../src/serverSetup'
5.363 ^
5.363 12:
5.363 13: // This is the set of middleware Wasp supplies by default.
5.363 at getRollupError (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:282:41)
5.363 at Object.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/parseAst.js:278:42)
5.363 at Module.error (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15290:28)
5.363 at Module.traceVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:15738:29)
5.363 at ModuleScope.findVariable (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:13426:39)
5.363 at Identifier.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:8362:40)
5.363 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.363 at CallExpression.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:10577:15)
5.363 at VariableDeclarator.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6231:23)
5.363 at VariableDeclaration.bind (/app/.wasp/build/server/node_modules/rollup/dist/shared/rollup.js:6227:28)
5.363
5.363
miho
miho7mo ago
Could you maybe share your main.wasp? The best thing for us to debug would be a Github repository with your code if that's something you feel comfortable sharing
Karan
KaranOP7mo ago
I mostly have the open saas template
Karan
KaranOP7mo ago
Thanks for looking into this @miho
miho
miho7mo ago
Okay, I have a hunch what you might have done wrong, but let me tell you the steps I did: 1. Create a new Open SaaS project 2. Create a file src/serverSetup.ts 3. Added the code
import logger from 'morgan';
import { type MiddlewareConfigFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig: any) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('logger', logger('combined'));
return middlewareConfig;
};
import logger from 'morgan';
import { type MiddlewareConfigFn } from 'wasp/server';

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig: any) => {
// Example of adding an extra domains to CORS.
middlewareConfig.set('logger', logger('combined'));
return middlewareConfig;
};
4. Added this to main.wasp
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
5. Installed morgan with npm install morgan@~1.10.0 and its types npm i --save-dev @types/morgan This setup works for me. Did you maybe put the serverMiddlewareFn in src/server and not src?
Karan
KaranOP7mo ago
This steps look like what I did as well. And I have place the serverSetup.ts in src directory root. Thanks for trying to replicate - strange that its working for you and not for me
martinsos
martinsos7mo ago
@Karan it is not highly unlikely it would work @miho and not for you: I would suggest trying to replicate his steps quite closely, to identify what the difference is, and that will point you to the issue almost certainly!
Karan
KaranOP7mo ago
@miho I can add you to the git repo is that helps - what is your handle?
miho
miho7mo ago
Please add @infomiho to the repo and I'll try it out 🙏
Karan
KaranOP7mo ago
Actually there isnt anything private in there - made it public here : https://github.com/ksk385/test-open-saas
GitHub
GitHub - ksk385/test-open-saas
Contribute to ksk385/test-open-saas development by creating an account on GitHub.
miho
miho7mo ago
I don't see this code:
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
server: {
middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
},
anywhere in the repository you shared?
Karan
KaranOP7mo ago
Sorry I havent pushe dup the latest!
MEE6
MEE67mo ago
Wohooo @Karan, you just became a Waspeteer level 3!
Karan
KaranOP7mo ago
Just pushed
miho
miho7mo ago
I've started your project successfully and I don't get the error you get 🤷‍♂️ - Which Wasp version are you using? - Did you try running wasp clean?
Karan
KaranOP7mo ago
I can try that. So a wasp build works for you successfully? The problem shows you when I build before deployment But I'll try the clean. Maybe there is some caching issues Sorry I meant the docker build. Since I am deploying manually Here is the command I am running from the app/.wasp/build folder:
docker build --platform=linux/amd64 -t test-open-saas:latest .
docker build --platform=linux/amd64 -t test-open-saas:latest .
Testing with the wasp clean command now, will keep you posted
miho
miho7mo ago
Nice! So you don't get the error with the setupFn?
Karan
KaranOP7mo ago
Yes after the wasp clean the docker build completes Yay! Does wasp clean do anything besides deleting the .wasp folder? Pushing up my build now to test on AWS Seems to be working fine. Please close this ticket as well! Thanks!
Want results from more Discord servers?
Add your server