Skip to content

Commit

Permalink
Reverting #745 to limit Debug logs (#780)
Browse files Browse the repository at this point in the history
* Reverting #745 to limit Debug logs
  • Loading branch information
vrdmr authored Nov 10, 2020
1 parent 05b0360 commit d76ff60
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion azure_functions_worker/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ 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)

# 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.')
logging_handler.flush()
Expand Down
9 changes: 5 additions & 4 deletions azure_functions_worker/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+ \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)
Expand Down
13 changes: 13 additions & 0 deletions tests/unittests/test_http_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import filecmp
import typing
import os
import unittest

import pytest

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d76ff60

Please sign in to comment.