I am using protractor having Jasmine where I intergrated stackdriver lib @google-cloud/logging. When I run this lib, I get entryId however I dont see logs in stackdriver. I debug the issues and seems like some issues with async-await concepts:
jasmine.getEnv().addReporter({
specDone: function (result) {
if(result.failedExpectations.length){
count++;
}
},
suiteDone: function (result) {
console.log(count);
if (count!=0) {
(async() => {
console.log('1')
await stackdriverLogEntry("Your GCP project", "protractor-log-data", "success: false");
console.log('2')
})()
} else {
(async() => {
console.log('3')
await stackdriverLogEntry("Your GCP project", "protractor-log-data", "success: true");
console.log('4')
})()
};
}
})
---------------------------------------------------------------------------
this.stackdriverLogEntry = async function (projectId, logName, text) {
// Creates a client
const logging = new Logging({ projectId: projectId });
// Selects the log to write to
const log = logging.log(logName);
// The metadata associated with the entry
const metadata = {
resource: { type: 'global' },
};
// Prepares a log entry
const entry = log.entry(metadata, text);
console.log(JSON.stringify(entry));
// Writes the log entry
await log.write(entry);
console.log(`metadata: ${JSON.stringify(metadata)}`);
console.log(`Logged: ${text}`);
};
Any HELP here would be appreciated!!!