From 22075d30e7caea5be9ed6d540735a2430a3e9097 Mon Sep 17 00:00:00 2001 From: Corie Watson Date: Mon, 16 Dec 2024 20:25:45 +0000 Subject: [PATCH] fix(logger): set utf-8 encoding --- setup.py | 2 +- src/firebase_functions/logger.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3294bc5..b1d4a27 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ install_requires = [ 'flask>=2.1.2', 'functions-framework>=3.0.0', 'firebase-admin>=6.0.0', 'pyyaml>=6.0', 'typing-extensions>=4.4.0', 'cloudevents==1.9.0', - 'flask-cors>=3.0.10', 'pyjwt[crypto]>=2.5.0', 'google-events>=0.5.0', + 'flask-cors>=3.0.10', 'pyjwt[crypto]>=2.5.0', 'google-events==0.5.0', 'google-cloud-firestore>=2.11.0' ] diff --git a/src/firebase_functions/logger.py b/src/firebase_functions/logger.py index 0285a7b..c381061 100644 --- a/src/firebase_functions/logger.py +++ b/src/firebase_functions/logger.py @@ -8,6 +8,11 @@ import typing as _typing import typing_extensions as _typing_extensions +# If encoding is not 'utf-8', change it to 'utf-8'. +if _sys.stdout.encoding != "utf-8": + _sys.stdout.reconfigure(encoding="utf-8") # type: ignore +if _sys.stderr.encoding != "utf-8": + _sys.stderr.reconfigure(encoding="utf-8") # type: ignore class LogSeverity(str, _enum.Enum): """