serve
serve copied to clipboard
How to call serve logs in client code
The serve package uses chalk to print helpful logs like when the server is starting and stopping. Is there way for me to call these APIs in my client code? This would be useful to log when a client loads a page in React or I make a request to my back end server from my client React app page.
const warning = (message) => chalk`{yellow WARNING:} ${message}`;
const info = (message) => chalk`{magenta INFO:} ${message}`;
const error = (message) => chalk`{red ERROR:} ${message}`;
I would want to use these warning, info, and error from serve directly. If i just call console.log it prints in my browser developer console, which is not what I want, I instead want the logs to be captured by the server so that those logs can also be captured by my Docker container too.
You might need a soution like Loggly or Sentry.io. Or add a logging route to your own API (which e.g. just pipes through the the request body to stdout).