Skip to content

Commit 24bef17

Browse files
committed
Fix logging of stderr data in command calls
The stderr data was presented as one blob without line breaks. Hard to read and smells like a bug. This commit fixes the output to become readable
1 parent 4bc5ae1 commit 24bef17

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

kiwi/command_process.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# You should have received a copy of the GNU General Public License
1616
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
1717
#
18+
import os
1819
import logging
1920
from collections import namedtuple
2021
from kiwi.command import CommandCallT
@@ -112,7 +113,8 @@ def poll_and_watch(self):
112113
)
113114
if error_output:
114115
log.debug('--------------err start-------------')
115-
log.debug(error_output)
116+
for line in error_output.split(os.linesep):
117+
log.debug(line)
116118
log.debug('--------------err stop--------------')
117119
return result(
118120
stderr=error_output, returncode=error_code
@@ -197,6 +199,7 @@ def __next__(self) -> PollT:
197199
elif byte_read == bytes(b'\n'):
198200
line_stderr = Codec.decode(self.command_error_line)
199201
self.command_error_line = bytes(b'')
202+
self.command_error_output += byte_read
200203
else:
201204
self.command_error_line += byte_read
202205
self.command_error_output += byte_read

test/unit/command_process_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test_poll_and_watch(self, mock_command):
140140
assert '--------------out start-------------' in self._caplog.text
141141
assert 'data' in self._caplog.text
142142
assert '--------------out stop--------------' in self._caplog.text
143-
assert result.stderr == 'error'
143+
assert result.stderr == 'error\n'
144144

145145
@patch('kiwi.command.Command')
146146
def test_create_match_method(self, mock_command):

0 commit comments

Comments
 (0)