设置 logger 对象

@param $logger

@throws Exception
961336
public function setLogger($logger)
    {
        if (!method_exists($logger, 'info'))
        {
            throw new Exception('logger need have method "info($message)"');
        }
        if (!method_exists($logger, 'error'))
        {
            throw new Exception('logger need have method "error($message)"');
        }
        $this->logger = $logger;
    }
182184
private function setLogger($logger)
    {
        $psr = 'Psr\\Log\\LoggerInterface';
        if (!is_a($logger, $psr)) {
            throw new InvalidArgumentException(
                sprintf('Expected an instance of %s', $psr)
            );
        }

        $this->logger = $logger;
    }
1058235
public static function registerExceptionHandler(Logger $logger)
    {
        // Only register once per instance
        if (self::$registeredExceptionHandler) {
            return false;
        }

        if ($logger === null) {
            throw new \Zend\Log\Exception\InvalidArgumentException('Invalid Logger specified');
        }

        set_exception_handler(
                    /* var $exception Exception */
            function (\Exception $exception) use ($logger) {
                    $msg = '';
                    $prev = $exception->getPrevious();
                    while ($prev !== null) {
                        $msg .= PHP_EOL.'Previous: '.$prev->getMessage().
                                 ' in '.$prev->getFile().' in line '.
                                 $prev->getLine().'.';
                        $prev = $prev->getPrevious();
                    }
                    $logger->log(ErrorLogger::ERR,
                            'Exception: '.$exception->getMessage().' in '.
                                     $exception->getFile().' in line '.
                                     $exception->getLine().'.'.$msg.PHP_EOL.
                                     'Trace:'.PHP_EOL.
                                     $exception->getTraceAsString());
                });
        self::$registeredExceptionHandler = true;

        return false;
    }
230256
function logError($errorMessage, \Exception $exception)
    {
        if ($this->logger instanceof LoggerInterface) {
            $this->logger->error($errorMessage . "\n" . $exception->getTraceAsString());
        }
    }
1362760
public function getLog(string $logger = 'default'): LoggerInterface
    {
        if (!isset($this->loggers[$logger])) {
            if ($logger === 'default') {
                if (!isset($this->implicit['logger'])) {
                    throw new \RuntimeException('The default logger was not set');
                }
                $this->loggers[$logger] = $this->implicit['logger'];
            } else {
                $this->loggers[$logger] = $this->getCollector()->getLogger($logger);
            }
        }

        return $this->loggers[$logger];
    }
816918
private function logException(\Exception $e)
    {
        if (isset($this->logger)) {
            $this->logger->notice(
                $e->getMessage(), [
                                    'code' => $e->getCode(),
                                    'line' => $e->getLine(),
                                    'file' => $e->getFile(),
                                ]
            );
        } else {
            // @codeCoverageIgnoreStart
            error_log(sprintf('[%s] [%s:%d] %s', $e->getCode(), $e->getFile(), $e->getLine(), $e->getMessage()), E_NOTICE);
            // @codeCoverageIgnoreEnd
        }
    }
356538
public function setLogger(GoracashLogger $logger)
    {
        $this->config->setLoggerClass(get_class($logger));
        $this->logger = $logger;
    }
718641
def set_logger(self, logger):
        
        self.__logger = logger
        self.session.set_logger(self.__logger)
1128251
public void setLogger(Logger logger) {
		this.logger = logger == null ? LoggerFactory.getLogger(getClass()) : logger;
	}
846452
public function logException( Exception $exception,
                                  $priority = Logger::CRIT )
    {
        /* @var $logger \Zork\Log\LoggerManager */
        $logger = $this->getServiceLocator()
                       ->get( 'Zork\Log\LoggerManager' );

        if ( $logger->hasLogger( 'exception' ) )
        {
            $logger->getLogger( 'exception' )
                   ->log( $priority,
                          '<pre>' . $exception . PHP_EOL . '</pre>' . PHP_EOL );
        }
    }
1294119
public function setLogger(LoggerInterface $logger)
    {
        foreach ($this->adapters as $adapter) {
            if ($adapter instanceof LoggerAwareInterface) {
                $adapter->setLogger($logger);
            }
        }
        $this->logger = $logger;
    }
248700
public function logError($error, $msg = '')
    {
        if (is_object($error)) {
            // we got exception object obviously
            $error = $error->getMessage();
        }
        $this->app->getLogger()->logLine($msg.' '.$error."\n", null, 'error');
    }
413236
public function addLogger(LoggerInterface $logger)
    {
        if ($this->isLoggerLoaded() && !($this->logger instanceof NullLogger)) {
            $logger = new LoggerAggregator([$logger, $this->logger]);
        }
        $this->logger = $logger;
        return $logger;
    }
893405
public static function register(LoggerInterface $logger = null)
    {
        $handler = new static($logger);

        set_error_handler(array($handler, 'handleError'));
        register_shutdown_function(array($handler, 'handleFatalError'));

        set_exception_handler(array($handler, 'handleException'));
    }
1289813
public void setLogger(Logger logger) {

		System.out.println("LOGGER set");
//		if(logger instanceof SimpleFileLogger) {
			this.logger = logger;
			System.out.println("appender added");
			this.logger.addAppender(this);
//		}
	}
267224
public function setLogger(LoggerInterface $logger):void{
		$this->logger = $logger;
		$this->driver->setLogger($logger);
		$this->query->setLogger($logger);
	}
1286724
public function setLogger($logger) {
		if(!in_array('Psr\Log\LoggerInterface', class_implements($logger, true))) {
			throw new \InvalidArgumentException('Logger object does not implement Psr\Log\LoggerInterface');
		}
		$this->logger = $logger;
	}