Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console.log() not logging in Functions > Logs #704

Closed
kyleabens opened this issue Jun 10, 2020 · 7 comments
Closed

console.log() not logging in Functions > Logs #704

kyleabens opened this issue Jun 10, 2020 · 7 comments

Comments

@kyleabens
Copy link

Related issues

[REQUIRED] Version info

node: 10

firebase-functions: 3.7.0

firebase-tools: 8.4.2

firebase-admin: 8.10.0

[REQUIRED] Test case

export const doSomething = functions.https.onCall(async (data, context) => {

  console.log('hello world');

});

[REQUIRED] Steps to reproduce

  1. Deploy a callable function with a console.log()
  2. Trigger function
  3. Go to Functions > Logs in the Firebase console

[REQUIRED] Expected behavior

It should log the different types of severity and be sortable in the firebase console

[REQUIRED] Actual behavior

Not logging any logs with a severity of 'INFO' when console.log() is used

Were you able to successfully deploy your functions?

Yes

@mbleigh
Copy link
Contributor

mbleigh commented Jun 10, 2020

Are you certain your function is getting triggered? onCall functions do some request validation and authentication before triggering the user codepath, my best guess is that the request isn't actually making it to your code in the first place.

Additionally, you might want to look into using the new logging SDK (see release notes) for Node 10.

@mbleigh mbleigh added the Needs: Author Feedback Issues awaiting author feedback label Jun 10, 2020
@kyleabens
Copy link
Author

kyleabens commented Jun 10, 2020

No it's making the request and everything operates as usual it's just all of my logging is messed up in my Firebase console. Here's an example of an error response from Stripe being emitted with console.log().

Screen Shot 2020-06-10 at 1 51 04 PM

It's separating every property to it's own line. Not sure why and I'm not able to sort by log level 'INFO' because none of this is given that log level even though it's being emitted with console.log

@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Jun 10, 2020
@mbleigh
Copy link
Contributor

mbleigh commented Jun 10, 2020

In that case the new logging API is definitely what you want instead. Try upgrading firebase-functions to 3.7.0 and using:

functions.logger.log('hello world')

and see if you're still experiencing similar issues.

@mbleigh mbleigh closed this as completed Jun 10, 2020
@kyleabens
Copy link
Author

@mbleigh Right so I did that and when I use functions.logger.log() I get a type error:

Property 'logger' does not exist on type 'typeof import("...functions/node_modules/firebase-functions/lib/index")'.ts

@mbleigh
Copy link
Contributor

mbleigh commented Jun 10, 2020

Are you certain you're on the latest SDK? The release was just yesterday:

npm i --save firebase-functions@^3.7.0

@kyleabens
Copy link
Author

Yep I just double checked to confirm. Could the way I'm importing it have anything to do with it? I use typescript.

import * as functions from 'firebase-functions';

functions.logger.log('hello world')

@kyleabens
Copy link
Author

Ugh all I had to do was restart VS Code. Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants