LogTrait - viames/pair GitHub Wiki

Pair framework: LogTrait

Pair\Traits\LogTrait adds convenient logging methods to classes.

Main methods

  • log(string $description, string $type = 'notice', string $subtext = ''): void
  • logError(string $description, string $subtext = ''): void
  • logWarning(string $description, string $subtext = ''): void
  • disableLogBar(): void

Implementation example

final class OrderService {
    use \Pair\Traits\LogTrait;

    public function run(): void {
        $this->log('Order sync started');

        try {
            // business logic
        } catch (\Throwable $e) {
            $this->logError('Order sync failed', $e->getMessage());
        }
    }
}

Notes

  • Helpful in services/controllers that need structured logs with minimal boilerplate.

See also: Log, LogBar.