Fixes to ios_logging (#41029)

* Logging size may not show up in config

* This is much simpler

* Avoid repetition in tests

* Both options of buffered are optional
This commit is contained in:
Nathaniel Case 2018-06-04 07:32:23 -04:00 committed by GitHub
commit 92a95368fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 43 deletions

View file

@ -225,18 +225,12 @@ def parse_size(line, dest):
size = None
if dest == 'buffered':
match = re.search(r'logging buffered (\S+)', line, re.M)
match = re.search(r'logging buffered(?: (\d+))?(?: [a-z]+)?', line, re.M)
if match:
try:
int_size = int(match.group(1))
except ValueError:
int_size = None
if int_size:
if isinstance(int_size, int):
size = str(match.group(1))
else:
size = str(4096)
if match.group(1) is not None:
size = match.group(1)
else:
size = "4096"
return size
@ -261,15 +255,12 @@ def parse_level(line, dest):
else:
if dest == 'buffered':
match = re.search(r'logging buffered (?:\d+ )([a-z]+)', line, re.M)
match = re.search(r'logging buffered(?: \d+)?(?: ([a-z]+))?', line, re.M)
else:
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
if match:
if match.group(1) in level_group:
level = match.group(1)
else:
level = 'debugging'
if match and match.group(1) in level_group:
level = match.group(1)
else:
level = 'debugging'