1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-31 18:30:15 +02:00

get issuer name from record param channel, instead of passing it through handler constructor

This commit is contained in:
pomaxa
2012-06-15 13:18:44 +03:00
parent 6a86fa4444
commit 6b4f4af85f
3 changed files with 31 additions and 28 deletions

28
pharIt.php Normal file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env php
<?php
$phar = new Phar('monolog.phar', 0, 'logger');
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->startBuffering();
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__.'/src/Monolog', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file) {
if (false !== strpos($file->getRealPath(), '.git')) {
continue;
}
$path = str_replace(realpath(__DIR__).'/', '', $file->getRealPath());
$phar->addFile($file->getRealPath(), $path);
echo "$path\n";
}
$phar->addFile('src/Monolog/Logger.php');
$phar->setDefaultStub('src/Monolog/Logger.php', 'Logger.php');
$phar->stopBuffering();
$phar->compressFiles(Phar::GZ);
unset($phar);

View File

@@ -21,12 +21,6 @@ class AmqpHandler extends AbstractProcessingHandler
*/ */
protected $exchange; protected $exchange;
/**
* Describes current issuer (e.g. "database", "landing", "server" and so on)
* @var string $issuer
*/
protected $issuer;
/** /**
* @param \AMQPExchange $exchange AMQP exchange, ready for use * @param \AMQPExchange $exchange AMQP exchange, ready for use
* @param string $exchangeName * @param string $exchangeName
@@ -34,9 +28,8 @@ class AmqpHandler extends AbstractProcessingHandler
* @param int $level * @param int $level
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
*/ */
public function __construct(\AMQPExchange $exchange, $exchangeName = 'log', $issuer = 'default', $level = Logger::DEBUG, $bubble = true) public function __construct(\AMQPExchange $exchange, $exchangeName = 'log', $level = Logger::DEBUG, $bubble = true)
{ {
$this->issuer = $issuer;
$this->exchange = $exchange; $this->exchange = $exchange;
$this->exchange->setName($exchangeName); $this->exchange->setName($exchangeName);
@@ -55,7 +48,7 @@ class AmqpHandler extends AbstractProcessingHandler
$routingKey = sprintf('%s.%s', $routingKey = sprintf('%s.%s',
substr($record['level_name'], 0, 4), substr($record['level_name'], 0, 4),
$this->getIssuer()); $record['channel']);
//we do not check return value because no handler really does //we do not check return value because no handler really does
$this->exchange->publish($data, $this->exchange->publish($data,
@@ -74,22 +67,4 @@ class AmqpHandler extends AbstractProcessingHandler
{ {
return new JsonFormatter(); return new JsonFormatter();
} }
/**
* Issuer setter
* @param string $issuer
*/
public function setIssuer($issuer)
{
$this->issuer = $issuer;
}
/**
* Issuer getter
* @return string
*/
public function getIssuer()
{
return $this->issuer;
}
} }

View File

@@ -34,7 +34,7 @@ class AmqpHandlerTest extends TestCase
{ {
$exchange = $this->getExchange(); $exchange = $this->getExchange();
$handler = new AmqpHandler($exchange, 'log', 'test'); $handler = new AmqpHandler($exchange, 'log');
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));