Closed
Description
Related issues
[REQUIRED] Version info
node: 16
firebase-functions: 4.4.0
firebase-tools: 11.24.1
firebase-admin: 10.3.0
[REQUIRED] Test case
exports.loggingtest = functions.https.onRequest((req, res) => {
functions.logger.info({
message: "we are healthy",
userId: "123",
});
res.status(200).send("OK");
});
[REQUIRED] Steps to reproduce
- Use code from "Test case"
- Call the function
- Open Cloud Logging Explorer
[REQUIRED] Expected behavior
[REQUIRED] Actual behavior
message
is an empty string.
Were you able to successfully deploy your functions?
Yes
Additional
When using @google-cloud/logging
, everything works:
// Imports the Google Cloud client library
import { Logging } from "@google-cloud/logging";
async function quickstart(
projectId = "PROJECT_ID", // Your Google Cloud Platform project ID
logName = "my-log" // The name of the log to write to
) {
// Creates a client
const logging = new Logging({ projectId });
// Selects the log to write to
const log = logging.log(logName);
// The metadata associated with the entry
const metadata = {
resource: { type: "global" },
// See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity
severity: "INFO",
};
const json = {
message: "Hello, world!",
userId: "123",
};
// Prepares a log entry
const entry = log.entry(metadata, json);
async function writeLog() {
// Writes the log entry
await log.write(entry);
console.log(`Logged: ${JSON.stringify(json)}`);
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
writeLog();
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
quickstart();
Metadata
Metadata
Assignees
Labels
No labels