Repository navigation
It is possible to use 'google-cloud/logging' in local with the firebase emulator ? #7513
Replies: 1 comment
|
That request to the metadata server is the library figuring out where it's running. It's normal behavior for Google Cloud libraries outside GCP. The emulator only warns you about the outbound request, it doesn't block it. What's actually eating your logs is that log.write(entry) isn't awaited. Your function finishes in 4 milliseconds, and the write hasn't gone out by the time the function ends. On deploy it looks fine because the instance stays warm and the write gets flushed later. The fix is to await the write, and make sure the handler awaits your logging function too. await log.write(entry)One thing to know: those logs land in real Cloud Logging, not the emulator UI, so check them in Logs Explorer in the console. Honestly, if you just need logs locally, the built-in Firebase Functions logger is enough, and it shows up directly in the emulator output. |
Uh oh!
There was an error while loading. Please reload this page.
When I try to log in locally using the Firebase Emulator with GCP logging, I can't use logging from the library
@google-cloud/logging. If I useconsole.log(), it works fine. I have already tried deploying the function, and logging with@google-cloud/loggingworks, just not locally.I get the following error when I try to run 'log.write(entry)':
My function code :
I have already tried setting up with a service account but still nothing:
If someone can help, it would be great.
All reactions