-
Notifications
You must be signed in to change notification settings - Fork 26
Unable to import logger #161
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
Comments
I'm also having this problem. The following code is broken, but when removing the logger import and logger.info(...) call, the code works and successfully deploys from firebase_functions import https_fn, logger
from firebase_admin import initialize_app, firestore
initialize_app()
@https_fn.on_request()
def write_data(req: https_fn.Request) -> https_fn.Response:
"""This function will take the request and write its data to cloud firestore in a collection called 'submissions'"""
#log that the function has been called
logger.info("write_data function called")
# Get the data from the request
data = req.get_json()
# Get the firestore client
firestore_client = firestore.client()
# Write the data to the firestore
firestore_client.collection("submissions").add(data)
# Return a response
return https_fn.Response("OK", 200) |
Seems like the logger feature was merged after the last release (0.1.2): #121 Anyway, strange that it is already mentioned in the official documentation. |
Too bad that the logger can not be imported in version 0.12, looking forward to the next release. Meanwhile, this is my workaround to get logs inside the emulator:
Output:
|
I think you can just copy paste the following file in your code for time being: |
I came here looking for a solution to this issue, but it seems to be fixed in 0.2.0 #167. Thanks Everyone! |
Since this issue is fixed in the latest version (sorry about that), I feel safe to close this issue. Thanks for your patience everyone :) |
I am trying to use the logger, just like in the example given here: https://firebase.google.com/docs/functions/writing-and-viewing-logs?gen=2nd
But when I try to deploy the function I get the following error message:
I am using the latest version (0.1.2) but indeed when I go into the
venv
folder where it is installed I don't see the logger file included. Any idea what is going on?The text was updated successfully, but these errors were encountered: