Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

45 linhas
939B

  1. <?php
  2. namespace Framework\Logging\Driver;
  3. use Monolog\Logger;
  4. use Monolog\Handler\StreamHandler;
  5. class StreamDriver implements Driver
  6. {
  7. private array $config;
  8. public function __construct(array $config)
  9. {
  10. $this->config = $config;
  11. }
  12. public function info(string $message): static
  13. {
  14. $this->logger()->info($message);
  15. return $this;
  16. }
  17. private function logger()
  18. {
  19. if (!isset($this->logger)) {
  20. $this->logger = new Logger($this->config['name']);
  21. $this->logger->pushHandler(new StreamHandler($this->config['path'], $this->config['minimum']));
  22. }
  23. return $this->logger;
  24. }
  25. public function warning(string $message): static
  26. {
  27. $this->logger()->warning($message);
  28. return $this;
  29. }
  30. public function error(string $message): static
  31. {
  32. $this->logger()->error($message);
  33. return $this;
  34. }
  35. }

Powered by TurnKey Linux.