Monolog log registry

Allows to get Logger instances in the global scope
via static method calls on this class.


$application = new Monolog\Logger('application');
$api = new Monolog\Logger('api');

Monolog\Registry::addLogger($application);
Monolog\Registry::addLogger($api);

function testLogger()
{

Monolog\Registry::api()->error('Sent to $api Logger instance');
Monolog\Registry::application()->error('Sent to $application Logger instance');

}

CloneableInstantiable
Methods
public static __callStatic( $name, $arguments)
 
Gets Logger instance from the registry via static method call

  • throws InvalidArgumentException If named Logger instance is not in the registry
  • return Monolog\Logger Requested instance of Logger
public static addLogger(Monolog\Logger $logger, ?string $name = NULL, bool $overwrite = false)
 
Adds new logging channel to the registry

  • throws InvalidArgumentException If $overwrite set to false and named Logger instance already exists
public static clear() : void
 
Clears the registry

public static getInstance( $name) : Monolog\Logger
 
Gets Logger instance from the registry

  • throws InvalidArgumentException If named Logger instance is not in the registry
public static hasLogger( $logger) : bool
 
Checks if such logging channel exists by name or instance

    public static removeLogger( $logger) : void
     
    Removes instance from registry by name or instance

      Properties
      private static $loggers
       
      List of all loggers in the registry (by named indexes)

      • var Logger[]
      Properties
      private static $loggers
       
      List of all loggers in the registry (by named indexes)

      • var Logger[]
      Methods
      public static __callStatic( $name, $arguments)
       
      Gets Logger instance from the registry via static method call

      • throws InvalidArgumentException If named Logger instance is not in the registry
      • return Monolog\Logger Requested instance of Logger
      public static addLogger(Monolog\Logger $logger, ?string $name = NULL, bool $overwrite = false)
       
      Adds new logging channel to the registry

      • throws InvalidArgumentException If $overwrite set to false and named Logger instance already exists
      public static clear() : void
       
      Clears the registry

      public static getInstance( $name) : Monolog\Logger
       
      Gets Logger instance from the registry

      • throws InvalidArgumentException If named Logger instance is not in the registry
      public static hasLogger( $logger) : bool
       
      Checks if such logging channel exists by name or instance

        public static removeLogger( $logger) : void
         
        Removes instance from registry by name or instance

          © 2020 Bruce Wells
          Search Namespaces \ Classes
          ConfigurationNumbers (0-9.) only