From 6ddf1542576e894f4516cf9fbbc27fec04804adc Mon Sep 17 00:00:00 2001 From: "Varad Meru [gmail]" Date: Tue, 10 Nov 2020 12:10:21 -0800 Subject: [PATCH 1/2] Reverting #745 to limit Debug logs --- azure_functions_worker/dispatcher.py | 2 +- azure_functions_worker/testutils.py | 2 +- tests/unittests/test_http_functions.py | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/azure_functions_worker/dispatcher.py b/azure_functions_worker/dispatcher.py index 04b144eb3..eed47873a 100644 --- a/azure_functions_worker/dispatcher.py +++ b/azure_functions_worker/dispatcher.py @@ -130,7 +130,7 @@ async def dispatch_forever(self): # established, should use it for system and user logs logging_handler = AsyncLoggingHandler() root_logger = logging.getLogger() - root_logger.setLevel(logging.DEBUG) + root_logger.setLevel(logging.INFO) root_logger.addHandler(logging_handler) logger.info('Switched to gRPC logging.') logging_handler.flush() diff --git a/azure_functions_worker/testutils.py b/azure_functions_worker/testutils.py index a965b5cf6..bb503dbb6 100644 --- a/azure_functions_worker/testutils.py +++ b/azure_functions_worker/testutils.py @@ -148,7 +148,7 @@ def wrapper(self, *args, __meth__=test_case, # Trim off host output timestamps host_output = getattr(self, 'host_out', '') output_lines = host_output.splitlines() - ts_re = r"^\[\d+\/\d+\/\d+ \d+\:\d+\:\d+.*(A|P)*M*\]" + ts_re = r"^\[\d+(\/|-)\d+(\/|-)\d+T*\d+\:\d+\:\d+.*(A|P)*M*\]" output = list(map( lambda s: re.sub(ts_re, '', s).strip(), output_lines)) diff --git a/tests/unittests/test_http_functions.py b/tests/unittests/test_http_functions.py index 673035e19..ba047ef2e 100644 --- a/tests/unittests/test_http_functions.py +++ b/tests/unittests/test_http_functions.py @@ -5,6 +5,7 @@ import filecmp import typing import os +import unittest import pytest @@ -98,22 +99,34 @@ def check_log_async_logging(self, host_out: typing.List[str]): self.assertIn('hello info', host_out) self.assertIn('and another error', host_out) + @unittest.skip("Reverting the debug logs PR as host currently cannot handle" + "apps with lot of debug statements. Reverting PR: " + "azure-functions-python-worker/pull/745") def test_debug_logging(self): r = self.webhost.request('GET', 'debug_logging') self.assertEqual(r.status_code, 200) self.assertEqual(r.text, 'OK-debug') + @unittest.skip("Reverting the debug logs PR as host currently cannot handle" + "apps with lot of debug statements. Reverting PR: " + "azure-functions-python-worker/pull/745") def check_log_debug_logging(self, host_out: typing.List[str]): self.assertIn('logging info', host_out) self.assertIn('logging warning', host_out) self.assertIn('logging debug', host_out) self.assertIn('logging error', host_out) + @unittest.skip("Reverting the debug logs PR as host currently cannot handle" + "apps with lot of debug statements. Reverting PR: " + "azure-functions-python-worker/pull/745") def test_debug_with_user_logging(self): r = self.webhost.request('GET', 'debug_user_logging') self.assertEqual(r.status_code, 200) self.assertEqual(r.text, 'OK-user-debug') + @unittest.skip("Reverting the debug logs PR as host currently cannot handle" + "apps with lot of debug statements. Reverting PR: " + "azure-functions-python-worker/pull/745") def check_log_debug_with_user_logging(self, host_out: typing.List[str]): self.assertIn('logging info', host_out) self.assertIn('logging warning', host_out) From c41193f591e98f49580d020057db43a9df474d73 Mon Sep 17 00:00:00 2001 From: "Varad Meru [gmail]" Date: Tue, 10 Nov 2020 12:19:22 -0800 Subject: [PATCH 2/2] nit; lint changes and adding helper comments --- azure_functions_worker/dispatcher.py | 2 ++ azure_functions_worker/testutils.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/azure_functions_worker/dispatcher.py b/azure_functions_worker/dispatcher.py index eed47873a..16f4da348 100644 --- a/azure_functions_worker/dispatcher.py +++ b/azure_functions_worker/dispatcher.py @@ -130,6 +130,8 @@ async def dispatch_forever(self): # established, should use it for system and user logs logging_handler = AsyncLoggingHandler() root_logger = logging.getLogger() + + # Don't change this unless you read #780 and #745 root_logger.setLevel(logging.INFO) root_logger.addHandler(logging_handler) logger.info('Switched to gRPC logging.') diff --git a/azure_functions_worker/testutils.py b/azure_functions_worker/testutils.py index bb503dbb6..c32ae467e 100644 --- a/azure_functions_worker/testutils.py +++ b/azure_functions_worker/testutils.py @@ -148,10 +148,11 @@ def wrapper(self, *args, __meth__=test_case, # Trim off host output timestamps host_output = getattr(self, 'host_out', '') output_lines = host_output.splitlines() - ts_re = r"^\[\d+(\/|-)\d+(\/|-)\d+T*\d+\:\d+\:\d+.*(A|P)*M*\]" - output = list(map( - lambda s: re.sub(ts_re, '', s).strip(), - output_lines)) + ts_re = r"^\[\d+(\/|-)\d+(\/|-)\d+T*\d+\:\d+\:\d+.*(" \ + r"A|P)*M*\]" + output = list(map(lambda s: + re.sub(ts_re, '', s).strip(), + output_lines)) # Execute check_log_ test cases self._run_test(__check_log__, host_out=output)