You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
>>> import sys
>>> import logging
>>> from google.cloud.logging_v2.handlers import CloudLoggingHandler
>>> from google.cloud import logging_v2 as glog
>>> log = logging.getLogger()
>>> client = glog.Client()
>>> cloudHandler = CloudLoggingHandler(client, name='logger')
>>> handlers = [cloudHandler]
>>> logging.basicConfig(level=logging.INFO, handlers=handlers)
>>> import pandas as pd
>>> x = pd.DataFrame()
>>> log.info(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 1308, in info
self._log(INFO, msg, args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 1444, in _log
self.handle(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 1454, in handle
self.callHandlers(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 1516, in callHandlers
hdlr.handle(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 861, in handle
rv = self.filter(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 720, in filter
result = f.filter(record)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/cloud/logging_v2/handlers/handlers.py", line 107, in filter
record._msg_str = str(record.msg).replace('"', '\\"') if record.msg else ""
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/generic.py", line 1576, in __nonzero__
.format(self.__class__.__name__))
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Activity
daniel-sanche commentedon Oct 4, 2021
Duplicate of #345
log.info(x)is part of the python logging standard library, which expects string inputs. You should turn the dataframe into a string before loggingI'm going to keep this open to see if we can handle this better internally though, since it's impacting multiple users