Skip to content

Commit

Permalink
Merge pull request #71 from rundeck-plugins/fix-log-output
Browse files Browse the repository at this point in the history
fix log output
  • Loading branch information
ltamaster authored Nov 9, 2022
2 parents 43f0b9f + db96876 commit c540397
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
15 changes: 10 additions & 5 deletions contents/container-inspect
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ p = Popen(
stdout=PIPE,
stderr=STDOUT
)

exitcode = p.wait()

if log_level == 'DEBUG':
log.debug("Command execution stdout: '%s' ..." % p.stdout.read())
log.debug("Command execution stderr: '%s' ..." % p.stderr.read())
else:
print(p.stdout.read())
# Print lines to stdout while waiting for command to finish
while True:
line = p.stdout.readline().rstrip()
if line:
print(line.decode())
if p.poll() is not None:
break

exitcode = p.poll()

if exitcode != 0:
log.error('Command execution failed with exit code: %s' % str(exitcode))
Expand Down
14 changes: 8 additions & 6 deletions contents/container-stats
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ p = Popen(
stdout=PIPE,
stderr=STDOUT
)
exitcode = p.wait()
# Print lines to stdout while waiting for command to finish
while True:
line = p.stdout.readline().rstrip()
if line:
print(line.decode())
if p.poll() is not None:
break

if log_level == 'DEBUG':
log.debug("Command execution stdout: '%s' ..." % p.stdout.read())
log.debug("Command execution stderr: '%s' ..." % p.stderr.read())
else:
print(p.stdout.read())
exitcode = p.poll()

if exitcode != 0:
log.error('Command execution failed with exit code: %s' % str(exitcode))
Expand Down

0 comments on commit c540397

Please sign in to comment.