Skip to content

Commit e3c4fcc

Browse files
author
Vladimir Kotal
committed
log output continuously from hook runs
fixes #2939
1 parent bb305b6 commit e3c4fcc

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

opengrok-tools/src/main/python/opengrok_tools/utils/command.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
#
21-
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
21+
# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2222
#
2323

2424
import logging
@@ -184,10 +184,10 @@ def run(self):
184184
self.out.append(line)
185185

186186
if self.doprint:
187-
# Even if print() fails the thread has to keep
187+
# Even if logging below fails, the thread has to keep
188188
# running to avoid hangups of the executed command.
189189
try:
190-
print(line.rstrip())
190+
self.logger.info(line.rstrip())
191191
except Exception as print_exc:
192192
self.logger.error(print_exc)
193193

opengrok-tools/src/main/python/opengrok_tools/utils/hook.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
#
21-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
21+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2222
#
2323

2424
from .command import Command
@@ -40,12 +40,10 @@ def run_hook(logger, script, path, env, timeout):
4040
logger.debug("Running hook '{}' in directory {}".
4141
format(script, path))
4242
cmd = Command([script], logger=logger, work_dir=path, env_vars=env,
43-
timeout=timeout)
43+
timeout=timeout, doprint=True)
4444
cmd.execute()
4545
if cmd.state != "finished" or cmd.getretcode() != SUCCESS_EXITVAL:
4646
logger.error("command failed: {} -> {}".format(cmd, cmd.getretcode()))
4747
ret = FAILURE_EXITVAL
4848

49-
logger.info("command output:\n{}".format(cmd.getoutputstr()))
50-
5149
return ret

0 commit comments

Comments
 (0)