Skip to content

Reverting #745 to limit Debug logs #780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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