Skip to content

Commit

Permalink
Merge pull request #126 from aizatto/master
Browse files Browse the repository at this point in the history
Use late static binding
  • Loading branch information
Seldaek committed Oct 21, 2012
2 parents fa292d1 + 938b608 commit 023b31a
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/Monolog/Logger.php
Expand Up @@ -108,8 +108,8 @@ public function __construct($name)
{
$this->name = $name;

if (!self::$timezone) {
self::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
if (!static::$timezone) {
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
}
}

Expand Down Expand Up @@ -183,15 +183,15 @@ public function popProcessor()
public function addRecord($level, $message, array $context = array())
{
if (!$this->handlers) {
$this->pushHandler(new StreamHandler('php://stderr', self::DEBUG));
$this->pushHandler(new StreamHandler('php://stderr', static::DEBUG));
}
$record = array(
'message' => (string) $message,
'context' => $context,
'level' => $level,
'level_name' => self::getLevelName($level),
'level_name' => static::getLevelName($level),
'channel' => $this->name,
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)))->setTimeZone(self::$timezone),
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)))->setTimeZone(static::$timezone),
'extra' => array(),
);
// check if any handler will handle this message
Expand Down Expand Up @@ -227,7 +227,7 @@ public function addRecord($level, $message, array $context = array())
*/
public function addDebug($message, array $context = array())
{
return $this->addRecord(self::DEBUG, $message, $context);
return $this->addRecord(static::DEBUG, $message, $context);
}

/**
Expand All @@ -239,7 +239,7 @@ public function addDebug($message, array $context = array())
*/
public function addInfo($message, array $context = array())
{
return $this->addRecord(self::INFO, $message, $context);
return $this->addRecord(static::INFO, $message, $context);
}

/**
Expand All @@ -251,7 +251,7 @@ public function addInfo($message, array $context = array())
*/
public function addNotice($message, array $context = array())
{
return $this->addRecord(self::NOTICE, $message, $context);
return $this->addRecord(static::NOTICE, $message, $context);
}

/**
Expand All @@ -263,7 +263,7 @@ public function addNotice($message, array $context = array())
*/
public function addWarning($message, array $context = array())
{
return $this->addRecord(self::WARNING, $message, $context);
return $this->addRecord(static::WARNING, $message, $context);
}

/**
Expand All @@ -275,7 +275,7 @@ public function addWarning($message, array $context = array())
*/
public function addError($message, array $context = array())
{
return $this->addRecord(self::ERROR, $message, $context);
return $this->addRecord(static::ERROR, $message, $context);
}

/**
Expand All @@ -287,7 +287,7 @@ public function addError($message, array $context = array())
*/
public function addCritical($message, array $context = array())
{
return $this->addRecord(self::CRITICAL, $message, $context);
return $this->addRecord(static::CRITICAL, $message, $context);
}

/**
Expand All @@ -299,7 +299,7 @@ public function addCritical($message, array $context = array())
*/
public function addAlert($message, array $context = array())
{
return $this->addRecord(self::ALERT, $message, $context);
return $this->addRecord(static::ALERT, $message, $context);
}

/**
Expand All @@ -311,7 +311,7 @@ public function addAlert($message, array $context = array())
*/
public function addEmergency($message, array $context = array())
{
return $this->addRecord(self::EMERGENCY, $message, $context);
return $this->addRecord(static::EMERGENCY, $message, $context);
}

/**
Expand All @@ -322,7 +322,7 @@ public function addEmergency($message, array $context = array())
*/
public static function getLevelName($level)
{
return self::$levels[$level];
return static::$levels[$level];
}

/**
Expand All @@ -337,7 +337,7 @@ public function isHandling($level)
'message' => '',
'context' => array(),
'level' => $level,
'level_name' => self::getLevelName($level),
'level_name' => static::getLevelName($level),
'channel' => $this->name,
'datetime' => new \DateTime(),
'extra' => array(),
Expand All @@ -363,7 +363,7 @@ public function isHandling($level)
*/
public function debug($message, array $context = array())
{
return $this->addRecord(self::DEBUG, $message, $context);
return $this->addRecord(static::DEBUG, $message, $context);
}

/**
Expand All @@ -377,7 +377,7 @@ public function debug($message, array $context = array())
*/
public function info($message, array $context = array())
{
return $this->addRecord(self::INFO, $message, $context);
return $this->addRecord(static::INFO, $message, $context);
}

/**
Expand All @@ -391,7 +391,7 @@ public function info($message, array $context = array())
*/
public function notice($message, array $context = array())
{
return $this->addRecord(self::NOTICE, $message, $context);
return $this->addRecord(static::NOTICE, $message, $context);
}

/**
Expand All @@ -405,7 +405,7 @@ public function notice($message, array $context = array())
*/
public function warn($message, array $context = array())
{
return $this->addRecord(self::WARNING, $message, $context);
return $this->addRecord(static::WARNING, $message, $context);
}

/**
Expand All @@ -419,7 +419,7 @@ public function warn($message, array $context = array())
*/
public function err($message, array $context = array())
{
return $this->addRecord(self::ERROR, $message, $context);
return $this->addRecord(static::ERROR, $message, $context);
}

/**
Expand All @@ -433,7 +433,7 @@ public function err($message, array $context = array())
*/
public function crit($message, array $context = array())
{
return $this->addRecord(self::CRITICAL, $message, $context);
return $this->addRecord(static::CRITICAL, $message, $context);
}

/**
Expand All @@ -447,7 +447,7 @@ public function crit($message, array $context = array())
*/
public function alert($message, array $context = array())
{
return $this->addRecord(self::ALERT, $message, $context);
return $this->addRecord(static::ALERT, $message, $context);
}

/**
Expand All @@ -461,6 +461,6 @@ public function alert($message, array $context = array())
*/
public function emerg($message, array $context = array())
{
return $this->addRecord(self::EMERGENCY, $message, $context);
return $this->addRecord(static::EMERGENCY, $message, $context);
}
}

0 comments on commit 023b31a

Please sign in to comment.