Skip to content

Commit e61e05a

Browse files
committed
Add more of logs output
1 parent f119bc2 commit e61e05a

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

run_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
cd testgres/tests
44
${PYTHON} -m unittest test_simple
55
flake8 --ignore=W191,F401,E501,F403 .
6+
cd ../..

testgres/testgres.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,22 +399,34 @@ def start(self, params={}):
399399

400400
if self.use_logging:
401401
tmpfile = tempfile.NamedTemporaryFile('w', dir=self.logs_dir, delete=False)
402-
logfile = tmpfile.name
402+
log_filename = tmpfile.name
403403

404-
self.logger = log_watch(self.name, logfile)
404+
self.logger = log_watch(self.name, log_filename)
405405
else:
406-
logfile = os.path.join(self.logs_dir, "postgresql.log")
406+
log_filename = os.path.join(self.logs_dir, "postgresql.log")
407407

408408
_params = {
409409
"-D": self.data_dir,
410410
"-w": None,
411-
"-l": logfile,
411+
"-l": log_filename,
412412
}
413413
_params.update(params)
414-
self.pg_ctl("start", _params)
414+
try:
415+
self.pg_ctl("start", _params)
416+
except ClusterException as e:
417+
print("\npg_ctl log:\n----")
418+
print(str(e))
419+
if os.path.exists(log_filename):
420+
print("\npostgresql.log:\n----")
421+
with open(log_filename, 'r') as logfile:
422+
text = logfile.readlines()[-1]
423+
print(text)
424+
else:
425+
print("Log file not found: %s", log_filename)
415426

416-
self.working = True
427+
raise ClusterException("Couldn't start the new node")
417428

429+
self.working = True
418430
return self
419431

420432
def status(self):

0 commit comments

Comments
 (0)