Closed Shnatsel closed 10 months ago
Hey, I faced this similar issue but for me the issue was that I was deploying my code to cloud run which was basically overwriting the logName in my case and the Logname that I passed to the logging.log("log-name") was buried in the jsonPayload.
Eg:
Thanks @Shnatsel for opening this issue and really sorry for late reply!
Apparently, it seems that printEntryMetadata
is async function and I believe that no results shown since your program exits before the printEntryMetadata
is executed. In order to make this work, I believe you could use printEntryMetadata().then()
for example, so for me it worked as expected. We definitely need to fix a sample though.
@RastogiAbhijeet, unfortunately for serverless environments logName
cannot be overriden if you use LogSync
- we have an open issue for this and awaiting for a fix. As of now the only way to see "original" logName
is embedded to jsonPayload
.
@losalex Any specific reason for doing so? Also Can I attempt to fix that one? ( If you can please point me to the issue ?
Thanks 😁
@RastogiAbhijeet, sorry for late response - when LogSync
is used, it prints log records to stdout
. All stdout
console output is picked up by serverless environments automatically and during the process logName
is changed - thats why a fix for this issue cannot be done in logging library.
Closing the issue as the empty entries issue is related to asynchronous tasks not called properly, and LogName
overriding is the expected behavior when using LogSync
.
Environment details
@google-cloud/logging
version: 10.3.1Steps to reproduce
For me this resulted in the following code:
which can be run with
node logging-bug-repro.js YOUR_PROJECT_ID
I have tried writing this myself before discovering the sample, and converged on basically the same code as the sample, which still always returns no elements. So I suspect the issue is with the client library rather than the sample.
The official sample is also not covered by tests.
Similar code in Go and Python works fine.