Skip to content

Commit db43e0c

Browse files
Add debug logging to signal handling and cleanup system
- Add debug logs when cleanup handlers are registered - Add debug logs in signal handler showing registered handler count - Add debug logs during cleanup execution showing each handler call - Improve error logging with handler index information 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 1ff1f50 commit db43e0c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Terminus.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ private function setupSignalHandlers(): void
566566
public function handleSignal(int $signal): void
567567
{
568568
$this->logger->notice('Received signal {signal}, performing cleanup...', ['signal' => $signal]);
569+
$this->logger->debug('Signal handler called with {count} cleanup handlers registered', ['count' => count($this->cleanup_handlers)]);
569570

570571
$this->cleanup();
571572

@@ -592,6 +593,7 @@ public static function getInstance(): ?self
592593
public function registerCleanupHandler(callable $handler): void
593594
{
594595
$this->cleanup_handlers[] = $handler;
596+
$this->logger->debug('Cleanup handler registered. Total handlers: {count}', ['count' => count($this->cleanup_handlers)]);
595597
}
596598

597599
/**
@@ -600,12 +602,16 @@ public function registerCleanupHandler(callable $handler): void
600602
private function cleanup(): void
601603
{
602604
try {
605+
$this->logger->debug('Starting cleanup with {count} handlers', ['count' => count($this->cleanup_handlers)]);
606+
603607
// Call all registered cleanup handlers
604-
foreach ($this->cleanup_handlers as $handler) {
608+
foreach ($this->cleanup_handlers as $index => $handler) {
605609
try {
610+
$this->logger->debug('Calling cleanup handler {index}', ['index' => $index]);
606611
call_user_func($handler);
612+
$this->logger->debug('Cleanup handler {index} completed successfully', ['index' => $index]);
607613
} catch (\Exception $e) {
608-
$this->logger->error('Error in cleanup handler: {message}', ['message' => $e->getMessage()]);
614+
$this->logger->error('Error in cleanup handler {index}: {message}', ['index' => $index, 'message' => $e->getMessage()]);
609615
}
610616
}
611617

0 commit comments

Comments
 (0)