Added some fluidity to Tlog setters
This commit is contained in:
@@ -164,6 +164,8 @@ class Tlog Implements LoggerInterface
|
|||||||
|
|
||||||
$this->loadDestinations($this->destinations, $classes_destinations);
|
$this->loadDestinations($this->destinations, $classes_destinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,48 +186,60 @@ class Tlog Implements LoggerInterface
|
|||||||
*/
|
*/
|
||||||
public function setLevel($level)
|
public function setLevel($level)
|
||||||
{
|
{
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPrefix($prefixe)
|
public function setPrefix($prefixe)
|
||||||
{
|
{
|
||||||
$this->prefixe = $prefixe;
|
$this->prefixe = $prefixe;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setFiles($files)
|
public function setFiles($files)
|
||||||
{
|
{
|
||||||
$this->files = explode(";", $files);
|
$this->files = explode(";", $files);
|
||||||
|
|
||||||
$this->all_files = in_array('*', $this->files);
|
$this->all_files = in_array('*', $this->files);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setIp($ips)
|
public function setIp($ips)
|
||||||
{
|
{
|
||||||
// isset($_SERVER['REMOTE_ADDR']) if we are in cli mode
|
// isset($_SERVER['REMOTE_ADDR']) if we are in cli mode
|
||||||
if (! empty($ips) && isset($_SERVER['REMOTE_ADDR']) && ! in_array($_SERVER['REMOTE_ADDR'], explode(";", $ips))) $this->level = self::MUET;
|
if (! empty($ips) && isset($_SERVER['REMOTE_ADDR']) && ! in_array($_SERVER['REMOTE_ADDR'], explode(";", $ips))) $this->level = self::MUET;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setShowRedirect($bool)
|
public function setShowRedirect($bool)
|
||||||
{
|
{
|
||||||
$this->show_redirect = $bool;
|
$this->show_redirect = $bool;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration d'une destination
|
// Configuration d'une destination
|
||||||
public function setConfig($destination, $param, $valeur)
|
public function setConfig($destination, $param, $valeur)
|
||||||
{
|
{
|
||||||
if (isset($this->destinations[$destination])) {
|
if (isset($this->destinations[$destination])) {
|
||||||
$this->destinations[$destination]->setConfig($param, $valeur);
|
$this->destinations[$destination]->setConfig($param, $valeur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration d'une destination
|
// Configuration d'une destination
|
||||||
public function getConfig($destination, $param)
|
public function getConfig($destination, $param)
|
||||||
{
|
{
|
||||||
if (isset($this->destinations[$destination])) {
|
if (isset($this->destinations[$destination])) {
|
||||||
return $this->destinations[$destination]->getConfig($param);
|
return $this->destinations[$destination]->getConfig($param);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methodes d'accès aux traces
|
// Methodes d'accès aux traces
|
||||||
@@ -510,14 +524,14 @@ class Tlog Implements LoggerInterface
|
|||||||
*/
|
*/
|
||||||
public function write(&$res)
|
public function write(&$res)
|
||||||
{
|
{
|
||||||
$this->done = true;
|
$this->done = true;
|
||||||
|
|
||||||
// Muet ? On ne fait rien
|
// Muet ? On ne fait rien
|
||||||
if ($this->level == self::MUET) return;
|
if ($this->level == self::MUET) return;
|
||||||
|
|
||||||
foreach ($this->destinations as $dest) {
|
foreach ($this->destinations as $dest) {
|
||||||
$dest->write($res);
|
$dest->write($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -650,11 +664,7 @@ class Tlog Implements LoggerInterface
|
|||||||
{
|
{
|
||||||
$text = '';
|
$text = '';
|
||||||
|
|
||||||
/*if (is_array($message)) {
|
if (is_scalar($message) === false) {
|
||||||
foreach ($message as $arg) {
|
|
||||||
$text .= is_scalar($arg) ? $arg : print_r($arg, true);
|
|
||||||
}
|
|
||||||
} else */ if (is_scalar($message) === false) {
|
|
||||||
$text = print_r($message, true);
|
$text = print_r($message, true);
|
||||||
} else {
|
} else {
|
||||||
$text = $message;
|
$text = $message;
|
||||||
|
|||||||
Reference in New Issue
Block a user