Finished log configuration. All loggers are currentrly working
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
use Thelia\Log\TlogDestinationConfig;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class TlogDestinationFile extends AbstractTlogDestination
|
||||
{
|
||||
@@ -41,7 +42,7 @@ class TlogDestinationFile extends AbstractTlogDestination
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->path_defaut = THELIA_ROOT . "log/" . self::TLOG_DEFAULT_NAME;
|
||||
$this->path_defaut = THELIA_ROOT . "log" . DS . self::TLOG_DEFAULT_NAME;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -69,12 +70,12 @@ class TlogDestinationFile extends AbstractTlogDestination
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "Text File";
|
||||
return Translator::getInstance()->trans('Text File');
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Store logs into text file";
|
||||
return Translator::getInstance()->trans('Store logs into text file');
|
||||
}
|
||||
|
||||
public function getConfigs()
|
||||
@@ -82,15 +83,15 @@ class TlogDestinationFile extends AbstractTlogDestination
|
||||
return array(
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_PATH_FILE,
|
||||
"Chemin du fichier",
|
||||
"Attention, vous devez indiquer un chemin absolu.<br />Le répertoire de base de votre Thelia est ".dirname(getcwd()),
|
||||
'Absolute file path',
|
||||
'You should enter an abolute file path. The base directory of your Thelia installation is '.THELIA_ROOT,
|
||||
$this->path_defaut,
|
||||
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 !",
|
||||
'File opening mode (A or E)',
|
||||
'Enter E to empty this file for each request, or A to always append logs. Consider resetting the file from time to time',
|
||||
self::VALEUR_MODE_DEFAULT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
use Thelia\Log\TlogDestinationConfig;
|
||||
|
||||
class TlogDestinationHtml extends AbstractTlogDestination
|
||||
{
|
||||
@@ -46,12 +47,12 @@ class TlogDestinationHtml extends AbstractTlogDestination
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "Affichage direct dans la page, en HTML";
|
||||
return "Direct HTML display";
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Permet d'afficher les logs directement dans la page resultat, avec une mise en forme HTML.";
|
||||
return "Display logs in HTML format, on top of generated pages.";
|
||||
}
|
||||
|
||||
public function getConfigs()
|
||||
@@ -59,8 +60,8 @@ class TlogDestinationHtml extends AbstractTlogDestination
|
||||
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.",
|
||||
"CSS of each log line",
|
||||
"You may also leave this field empty, and define a \"tlog-trace\" style in your CSS.",
|
||||
self::VALEUR_STYLE_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTAREA
|
||||
)
|
||||
@@ -71,6 +72,6 @@ class TlogDestinationHtml extends AbstractTlogDestination
|
||||
{
|
||||
$block = sprintf('<pre class="tlog-trace" style="%s">%s</pre>', $this->style, htmlspecialchars(implode("\n", $this->_logs)));
|
||||
|
||||
$this->InsertAfterBody($res, $block);
|
||||
$this->insertAfterBody($res, $block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : thelia@openstudio.fr */
|
||||
/* web : http://www.openstudio.fr */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
|
||||
class TlogDestinationJavascriptConsole extends AbstractTlogDestination {
|
||||
|
||||
public function getTitle() {
|
||||
return "Browser's Javascript console";
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return "The Thelia logs are displayed in your browser's Javascript console.";
|
||||
}
|
||||
|
||||
public function write(&$res) {
|
||||
|
||||
$content = '<script>try {'."\n";
|
||||
|
||||
foreach($this->_logs as $line) {
|
||||
$content .= "console.log('".str_replace("'", "\\'", str_replace(array("\r\n", "\r", "\n"), '\\n', $line))."');\n";
|
||||
}
|
||||
|
||||
$content .= '} catch(ex) { alert("Les logs Thelia ne peuvent être affichés dans la console javascript:" + ex); }</script>'."\n";
|
||||
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$content</html>", $res);
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,12 @@ class TlogDestinationNull extends AbstractTlogDestination
|
||||
{
|
||||
public function getTitle()
|
||||
{
|
||||
return "Trou noir";
|
||||
return "Black hole";
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Cette destination ne provoque aucune sortie";
|
||||
return "This destinations consumes the logs but don't display them";
|
||||
}
|
||||
|
||||
public function add($string)
|
||||
|
||||
111
core/lib/Thelia/Log/Destination/TlogDestinationPopup.php
Normal file
111
core/lib/Thelia/Log/Destination/TlogDestinationPopup.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : thelia@openstudio.fr */
|
||||
/* web : http://www.openstudio.fr */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
use Thelia\Log\TlogDestinationConfig;
|
||||
|
||||
class TlogDestinationPopup extends AbstractTlogDestination {
|
||||
|
||||
// Nom des variables de configuration
|
||||
// ----------------------------------
|
||||
const VAR_POPUP_WIDTH = "tlog_destinationpopup_width";
|
||||
const VALEUR_POPUP_WIDTH_DEFAUT = "600";
|
||||
|
||||
const VAR_POPUP_HEIGHT = "tlog_destinationpopup_height";
|
||||
const VALEUR_POPUP_HEIGHT_DEFAUT = "600";
|
||||
|
||||
const VAR_POPUP_TPL = "tlog_destinationpopup_template";
|
||||
// Ce fichier doit se trouver dans le même répertoire que TlogDestinationPopup.class.php
|
||||
const VALEUR_POPUP_TPL_DEFAUT = "TlogDestinationPopup.tpl";
|
||||
|
||||
public function getTitle() {
|
||||
return "Javascript popup window";
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return "Display logs in a popup window, separate from the main window .";
|
||||
}
|
||||
|
||||
public function getConfigs() {
|
||||
return array(
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_TPL,
|
||||
"Popup windows template",
|
||||
"Put #LOGTEXT in the template text where you want to display logs..",
|
||||
file_get_contents(__DIR__.DS. self::VALEUR_POPUP_TPL_DEFAUT),
|
||||
TlogDestinationConfig::TYPE_TEXTAREA
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_HEIGHT,
|
||||
"Height of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_HEIGHT_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_WIDTH,
|
||||
"Width of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_WIDTH_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function write(&$res) {
|
||||
|
||||
$content = ""; $count = 1;
|
||||
|
||||
foreach($this->_logs as $line) {
|
||||
$content .= "<div class=\"".($count++ % 2 ? "paire" : "impaire")."\">".htmlspecialchars($line)."</div>";
|
||||
}
|
||||
|
||||
$tpl = $this->getConfig(self::VAR_POPUP_TPL);
|
||||
|
||||
$tpl = str_replace('#LOGTEXT', $content, $tpl);
|
||||
$tpl = str_replace(array("\r\n", "\r", "\n"), '\\n', $tpl);
|
||||
|
||||
$wop = sprintf('
|
||||
<script>
|
||||
_thelia_console = window.open("","thelia_console","width=%s,height=%s,resizable,scrollbars=yes");
|
||||
if (_thelia_console == null) {
|
||||
alert("The log popup window could not be opened. Please disable your popup blocker for this site.");
|
||||
}
|
||||
else {
|
||||
_thelia_console.document.write("%s");
|
||||
_thelia_console.document.close();
|
||||
}
|
||||
</script>',
|
||||
$this->getConfig(self::VAR_POPUP_WIDTH),
|
||||
$this->getConfig(self::VAR_POPUP_HEIGHT),
|
||||
str_replace('"', '\\"', $tpl)
|
||||
);
|
||||
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$wop\n</body>", $res);
|
||||
else
|
||||
$res .= $wop;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Log/Destination/TlogDestinationPopup.tpl
Normal file
52
core/lib/Thelia/Log/Destination/TlogDestinationPopup.tpl
Normal file
@@ -0,0 +1,52 @@
|
||||
<!--
|
||||
Default template for TlogDestinationPopup. Insert #LOGTEXT where you want to
|
||||
write the log text in your template.
|
||||
-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Thelia logs</title>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: "Courier New", courier, fixed;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
background-color: #868F99;
|
||||
border-bottom: 2px solid #127AED;
|
||||
color: #FFFFFF;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-weight: bold;
|
||||
line-height: 20px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.paire {
|
||||
background-color: #EBEDEE;
|
||||
padding: 5px;
|
||||
border-bottom: 1px dotted #fff;
|
||||
}
|
||||
|
||||
.impaire {
|
||||
background-color: #D4DADD;
|
||||
padding: 5px;
|
||||
border-bottom: 1px dotted #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Thelia Debug</h1>
|
||||
<pre>#LOGTEXT</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -34,12 +34,12 @@ class TlogDestinationText extends AbstractTlogDestination
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "Affichage direct dans la page, en texte brut";
|
||||
return "Direct text display";
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Permet d'afficher les logs directement dans la page resultat, au format texte brut.";
|
||||
return "Display logs in raw text format, on top of generated pages.";
|
||||
}
|
||||
|
||||
public function add($texte)
|
||||
|
||||
Reference in New Issue
Block a user