I’ve set up an Angular SSR on a Firebase function. Now I try to debug a few things, but something I’m missing.
I’ve imported the functions
import functions from 'firebase-functions';
and try to use them in my Express calls
server.get('*', (req, res) => {
const hostUrl = `${req.protocol}://${req.get('Host')}`;
const userAgent = req.header('User-Agent');
// Leveraging PWA if not a robot
if (isbot(userAgent)) {
functions.logger.debug(`Using SSR on user agent ${userAgent}`);
res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }, {provide: HOST_URL, useValue: hostUrl}] });
} else {
functions.logger.debug(`Using PWA on user agent ${userAgent}`);
res.sendFile(join(distFolder, 'index.html'));
}
});
If not done everything wrong I should log these messages. But if looking at Log Explorer of GCP I cannot see my log entries. Am I looking at the wrong place or what is my mistake?
It might be that the Cloud Logging API is not enabled.
To enable the Cloud Logging API, please follow the steps below:
Go to the GCP Console of your project. From the navigation menu, go to API and services. Go to Libraries, and search for Cloud Logging API. Select the Cloud Logging API. Click on enable.
You can refer to documentation on how to enable the Cloud Logging API.
Please try checking the stdout logs in the Cloud Logging/Logs explorer after enabling the API. You can refer to documentation for more information regarding Cloud Logging API and how the API performs logging-related tasks, including reading and writing log entries, creating log-based metrics, and managing sinks to route logs.