Reputation: 4561
I see tons of spam log messages in the firebase functions log console, but I cannot see the ones I log, so the ones I expect to see.
My code:
const createNotification = ((notification) => {
return admin.firestore().collection('notifications')
.add(notification)
.then(doc => console.log('notification added', doc)); //THIS IS THE LOG I EXPECT TO SEE
});
exports.userJoined = functions.auth.user()
.onCreate(user => {
return admin.firestore().collection('users')
.doc(user.uid).get().then(doc => {
const newUser = doc.data();
const notification = {
content: 'Joined the party',
user: `${newUser.firstName} ${newUser.lastName}`,
time: admin.firestore.FieldValue.serverTimestamp()
};
return createNotification(notification);
});
});
In the promise I also tried: .then(() => console.log('notification added', notification));
The notification is created in the database but no log in the conosole.
This time I am lucky and the code works, but in the case the code is not working I would like to be able to log stuff out.
In my reduxfirebase config I got enableLogging to true, in case that could make any difference.
export const reduxFirebase = {
userProfile: 'users',
useFirestoreForProfile: true,
enableLogging: true
}
Any tip to debug server function execution in firebase also will be much appreciatted. Thanks
EDIT: Image of the obtained firebase log:
Expected log:
Upvotes: 0
Views: 2946
Reputation: 26313
Try replacing console.log
with functions.logger.info
-- I think what's happening is your log is getting exploded onto multiple lines in a way that reads confusingly.
Upvotes: 2