HyukjinKwon commented on code in PR #39212:
URL: https://github.com/apache/spark/pull/39212#discussion_r1057461596
##########
python/pyspark/sql/connect/client.py:
##########
@@ -36,6 +41,49 @@
)
+def _configure_logging() -> logging.Logger:
+ """Configure logging for the Spark Connect clients."""
+ logger = logging.getLogger("pyspark.sql.connect.client")
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logging.Formatter(fmt="%(asctime)s %(process)d %(levelname)s
%(funcName)s %(message)s")
+ )
+ logger.addHandler(handler)
+
+ # Check the environment variables for log levels:
+ level = os.getenv("SPARK_CONNECT_LOG_LEVEL", "none").lower()
+ if level == "info":
+ logger.setLevel(logging.INFO)
+ elif level == "warn":
+ logger.setLevel(logging.WARNING)
+ elif level == "error":
+ logger.setLevel(logging.ERROR)
+ elif level == "debug":
+ logger.setLevel(logging.DEBUG)
+ else:
+ logger.disabled = True
+ return logger
+
+
+# Instantiate the logger based on the environment configuration.
+_logger = _configure_logging()
Review Comment:
nit ... but .. maybe we could just define `__all__` here to expose it as an
API e.g., exception classes, and forgot about naming with prefix `_`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]