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
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?
Here is an example of log messages
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.Thanks so much I will try these out!
It's great to be able to configure express from wasp!
Yeah, we need to have an escape hatch for all the stuff we don't do (yet!)
Glad you like it!
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
Any idea whats going wrong here?Are you importing it like this in the Wasp file?
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:
So I was using the named import but moved to your suggested import and still seeing the issue:
I even tried doing a named export instead of default export like this
and setup a named import like this
getting this output:
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 sharingThanks for looking into this @miho
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
4. Added this to main.wasp
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
?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@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!
@miho I can add you to the git repo is that helps - what is your handle?
Please add @infomiho to the repo and I'll try it out 🙏
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.
I don't see this code:
anywhere in the repository you shared?
Sorry I havent pushe dup the latest!
Wohooo @Karan, you just became a Waspeteer level 3!
Just pushed
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
?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:
Testing with the wasp clean
command now, will keep you postedNice! So you don't get the error with the
setupFn
?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!