eventLog = []; $this->logMode = $mode; return $this; } public function logMode(): LogMode { return $this->logMode; } public function getLog(): array { return $this->eventLog; } public function logEvent(TenancyEvent $event): static { $this->eventLog[] = ['time' => now(), 'event' => $event::class, 'tenant' => $this->tenant]; return $this; } public function dump(Closure $dump = null): static { $dump ??= dd(...); // Dump the log if we were already logging in silent mode // Otherwise start logging in instant mode match ($this->logMode) { LogMode::NONE => $this->log(LogMode::INSTANT), LogMode::SILENT => $dump($this->eventLog), LogMode::INSTANT => null, }; return $this; } public function dd(Closure $dump = null): void { $dump ??= dd(...); if ($this->logMode === LogMode::SILENT) { $dump($this->eventLog); } else { $dump($this); } } }