pkg-config wrapper: disable logging by default

This commit is contained in:
alexey.lysiuk 2021-09-08 10:19:21 +03:00
parent c15e85e713
commit d9585fd22a

View file

@ -25,12 +25,22 @@ import subprocess
import sys import sys
_LOG_FILENAME = '' # 'pkg-config.log'
def _write_log(message: str):
if not _LOG_FILENAME:
return
with open(_LOG_FILENAME, 'a') as log:
log.write(message)
def _main(): def _main():
args = sys.argv[1:] args = sys.argv[1:]
with open('pkg-config.log', 'a') as log:
cmdline = ' '.join(map(shlex.quote, args)) cmdline = ' '.join(map(shlex.quote, args))
log.write(f'% pkg-config {cmdline}\n') _write_log(f'% pkg-config {cmdline}\n')
bin_path = Path(__file__).parent bin_path = Path(__file__).parent
prefix_path = bin_path.parent prefix_path = bin_path.parent
@ -50,11 +60,10 @@ def _main():
stdout = result.stdout.decode('ascii') stdout = result.stdout.decode('ascii')
stderr = result.stderr.decode('ascii') stderr = result.stderr.decode('ascii')
with open('pkg-config.log', 'a') as log: _write_log('out> ')
log.write('out> ') _write_log(stdout if stdout else '\n')
log.write(stdout if stdout else '\n') _write_log('err> ')
log.write('err> ') _write_log(stderr if stderr else '\n')
log.write(stderr if stderr else '\n')
sys.stdout.write(stdout) sys.stdout.write(stdout)
sys.stderr.write(stderr) sys.stderr.write(stderr)