firebase/functions-samples

[DOCS] for sample: monitor-cloud-logging : logging submodule

mouadessalim opened this issue · 1 comments

Which sample?

What is the issue with this sample's docs?

Description:

I encountered an issue while trying to use the logger submodule from the firebase_functions module. According to the documentation and examples, it seems like there should be a logger submodule available, but it doesn't exist in the installed package.

Steps to Reproduce:

  1. Install firebase_functions using pip.

  2. Attempt to import the logger submodule as shown below:

    from firebase_functions import logger
  3. Run the script.

Expected Behavior:
The logger submodule should be imported without any errors.

Actual Behavior:
The following error is raised: ImportError: cannot import name 'logger' from 'firebase_functions' (/path/to/venv/lib/python3.12/site-packages/firebase_functions/init.py)

Check that you have the latest version of firebase-functions installed. I had the same issue and checked pip to see that I was on version 0.1.2 for some reason when setting up firebase functions as explained in their docs.

If you are using a venv inside your firebase functions folder, you can simply activate the environment using

venv\Scripts\activate

on Windows. The Path for Linux should be slightly different but similar. After activting the venv, you can use

pip list

to show the currently installed packages with their version and

pip install --upgrade firebase-functions

to install the latest version which should contain the logging module.

The only question left is why Firebase installs such an old version of firebase-functions when running the firebase init functions command to create a python functions directory.