mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-20 01:24:42 +04:00
replaced str concat with .write_line(); replaced \t with spaces; removed trailing space in logs
This commit is contained in:
parent
e0155fbd66
commit
cb164ef629
2 changed files with 26 additions and 16 deletions
|
|
@ -37,22 +37,32 @@ def _log_and_exit(msg, exc, formatted):
|
||||||
log_path = os.path.join(store.directory, 'pre-commit.log')
|
log_path = os.path.join(store.directory, 'pre-commit.log')
|
||||||
output.write_line('Check the log at {}'.format(log_path))
|
output.write_line('Check the log at {}'.format(log_path))
|
||||||
|
|
||||||
meta_info_msg = '### version information\n```\n'
|
with open(log_path, 'wb') as log:
|
||||||
meta_info_msg += 'pre-commit.version: {}\n'.format(C.VERSION)
|
output.write_line(
|
||||||
meta_info_msg += 'sys.version: \n{}\n'.format(
|
'### version information\n```', stream=log,
|
||||||
|
)
|
||||||
|
output.write_line(
|
||||||
|
'pre-commit.version: {}'.format(C.VERSION), stream=log,
|
||||||
|
)
|
||||||
|
output.write_line(
|
||||||
|
'sys.version:\n{}'.format(
|
||||||
'\n'.join(
|
'\n'.join(
|
||||||
[
|
[
|
||||||
'\t{}'.format(line)
|
' {}'.format(line)
|
||||||
for line in sys.version.splitlines()
|
for line in sys.version.splitlines()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
stream=log,
|
||||||
)
|
)
|
||||||
meta_info_msg += 'sys.executable: {}\n'.format(sys.executable)
|
output.write_line(
|
||||||
meta_info_msg += 'os.name: {}\n'.format(os.name)
|
'sys.executable: {}'.format(sys.executable), stream=log,
|
||||||
meta_info_msg += 'sys.platform: {}\n```\n'.format(sys.platform)
|
)
|
||||||
meta_info_msg += '### error information\n```\n'
|
output.write_line('os.name: {}'.format(os.name), stream=log)
|
||||||
with open(log_path, 'wb') as log:
|
output.write_line(
|
||||||
output.write(meta_info_msg, stream=log)
|
'sys.platform: {}\n```'.format(sys.platform), stream=log,
|
||||||
|
)
|
||||||
|
output.write_line('### error information\n```', stream=log)
|
||||||
output.write(error_msg, stream=log)
|
output.write(error_msg, stream=log)
|
||||||
output.write_line(formatted, stream=log)
|
output.write_line(formatted, stream=log)
|
||||||
output.write('\n```\n', stream=log)
|
output.write('\n```\n', stream=log)
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ def test_log_and_exit(cap_out, mock_store_dir):
|
||||||
r'^### version information\n'
|
r'^### version information\n'
|
||||||
r'```\n'
|
r'```\n'
|
||||||
r'pre-commit.version: \d+\.\d+\.\d+\n'
|
r'pre-commit.version: \d+\.\d+\.\d+\n'
|
||||||
r'sys.version: (.*\n)*'
|
r'sys.version:\n( .*\n)*'
|
||||||
r'sys.executable: .*\n'
|
r'sys.executable: .*\n'
|
||||||
r'os.name: .*\n'
|
r'os.name: .*\n'
|
||||||
r'sys.platform: .*\n'
|
r'sys.platform: .*\n'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue