refactor Thelia logger

This commit is contained in:
Manuel Raynaud
2013-01-19 10:23:18 +01:00
parent 99092c27f2
commit b493d950f0
7 changed files with 91 additions and 123 deletions

View File

@@ -34,19 +34,18 @@ class TlogDestinationFile extends AbstractTlogDestination
const TLOG_DEFAULT_NAME = "log-thelia.txt";
const VAR_MODE = "tlog_destinationfile_mode";
const VALEUR_MODE_DEFAUT = "A";
const VALEUR_MODE_DEFAULT = "A";
protected $path_defaut = false;
protected $fh = false;
public function __construct($configModel = null)
public function __construct()
{
$this->path_defaut = THELIA_ROOT . "log/" . self::TLOG_DEFAULT_NAME;
$this->setConfigModel($configModel);
parent::__construct();
}
public function configurer($config = false)
public function configurer()
{
$file_path = $this->get_config(self::VAR_PATH_FILE);
$mode = strtolower($this->get_config(self::VAR_MODE)) == 'a' ? 'a' : 'w';
@@ -83,16 +82,14 @@ class TlogDestinationFile extends AbstractTlogDestination
"Chemin du fichier",
"Attention, vous devez indiquer un chemin absolu.<br />Le répertoire de base de votre Thelia est ".dirname(getcwd()),
$this->path_defaut,
TlogDestinationConfig::TYPE_TEXTFIELD,
$this->getConfigModel()
TlogDestinationConfig::TYPE_TEXTFIELD
),
new TlogDestinationConfig(
self::VAR_MODE,
"Mode d'ouverture (A ou E)",
"Indiquez E pour ré-initialiser le fichier à chaque requête, A pour ne jamais réinitialiser le fichier. Pensez à le vider de temps en temps !",
self::VALEUR_MODE_DEFAUT,
TlogDestinationConfig::TYPE_TEXTFIELD,
$this->getConfigModel()
self::VALEUR_MODE_DEFAULT,
TlogDestinationConfig::TYPE_TEXTFIELD
)
);
}

View File

@@ -40,7 +40,7 @@ class TlogDestinationHtml extends AbstractTlogDestination
}
public function configurer($config = false)
public function configurer()
{
$this->style = $this->get_config(self::VAR_STYLE);
}
@@ -57,15 +57,15 @@ class TlogDestinationHtml extends AbstractTlogDestination
public function get_configs()
{
// return array(
// new TlogDestinationConfig(
// self::VAR_STYLE,
// "Style d'affichage direct dans la page",
// "Vous pouvez aussi laisser ce champ vide, et créer un style \"tlog-trace\" dans votre feuille de style.",
// self::VALEUR_STYLE_DEFAUT,
// TlogDestinationConfig::TYPE_TEXTAREA
// )
// );
return array(
new TlogDestinationConfig(
self::VAR_STYLE,
"Style d'affichage direct dans la page",
"Vous pouvez aussi laisser ce champ vide, et créer un style \"tlog-trace\" dans votre feuille de style.",
self::VALEUR_STYLE_DEFAUT,
TlogDestinationConfig::TYPE_TEXTAREA
)
);
}
public function ecrire(&$res)