Skip to content
Snippets Groups Projects
Select Git revision
  • 1b1a594eda1d3d358b0cd629eb950d48da52903d
  • master default protected
  • 5.x
  • ll-php8-bs5
  • release_5_bs5
  • ll-php8
  • 4.x
  • laminas_migration
  • release_1.0.0.2
  • release_4.0.0
  • release_3.2.8
  • bootstrap4_migration
  • 1.0.0.3
  • 6.0.7
  • 6.0.6
  • 6.0.5
  • 6.0.4
  • 6.0.3
  • 6.0.2
  • 6.0.1
  • 5.1.1
  • 6.0.0
  • 5.1.0
  • 5.0.0
  • 4.0.2
  • 3.2.11
  • 4.0.1
  • 3.2.10
  • 4.0.0
  • 1.0.0.2
  • 3.2.9
  • 3.2.8
32 results

autoload_classmap.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    LoggerAwareTrait.php 1.40 KiB
    <?php
    
    namespace Unicaen\BddAdmin\Logger;
    
    use Symfony\Component\Console\Style\SymfonyStyle;
    
    trait LoggerAwareTrait
    {
    
        protected ?LoggerInterface $logger = null;
    
    
    
        /**
         * @return LoggerInterface|null
         */
        public function getLogger(): ?LoggerInterface
        {
            return $this->logger;
        }
    
    
    
        /**
         * @param LoggerInterface|null $logger
         *
         * @return self
         */
        public function setLogger(null|LoggerInterface|SymfonyStyle $logger): self
        {
            if ($logger instanceof SymfonyStyle){
                $logger = new SymfonyStyleLogger($logger);
            }
            $this->logger = $logger;
    
            return $this;
        }
    
    
    
        public function logTitle(string $title): void
        {
            if ($this->logger) $this->logger->title($title);
        }
    
    
        public function logSuccess(string $message): void
        {
            if ($this->logger) $this->logger->success($message);
        }
    
    
        public function logError(string|\Throwable $e): void
        {
            if ($this->logger) $this->logger->error($e);
        }
    
    
    
        public function logBegin(string $title): void
        {
            if ($this->logger) $this->logger->begin($title);
        }
    
    
    
        public function logEnd(?string $msg = null): void
        {
            if ($this->logger) $this->logger->end($msg);
        }
    
    
    
        public function logMsg(string $message, bool $rewrite = false): void
        {
            if ($this->logger) $this->logger->msg($message, $rewrite);
        }
    }