diff --git a/src/includes/class/class.LSattr_html.php b/src/includes/class/class.LSattr_html.php
index 3bc316dd..d373af1a 100644
--- a/src/includes/class/class.LSattr_html.php
+++ b/src/includes/class/class.LSattr_html.php
@@ -54,6 +54,15 @@ class LSattr_html extends LSlog_staticLoggerClass {
return true;
}
+ /**
+ * Allow conversion of LSattr_html to string
+ *
+ * @retval string The string representation of the LSattr_html
+ */
+ public function __toString() {
+ return "<".get_class($this)." ".$this -> name.">";
+ }
+
/**
* Retourne le label de l'attribut
*
diff --git a/src/includes/class/class.LSform.php b/src/includes/class/class.LSform.php
index 7ed1cc6d..6807020b 100644
--- a/src/includes/class/class.LSform.php
+++ b/src/includes/class/class.LSform.php
@@ -75,6 +75,15 @@ class LSform extends LSlog_staticLoggerClass {
LSsession :: loadLSclass('LSformElement');
}
+ /**
+ * Allow conversion of LSform to string
+ *
+ * @retval string The string representation of the LSform
+ */
+ public function __toString() {
+ return " idForm." on ".$this -> ldapObject -> toString(false).">";
+ }
+
/**
* Display the form
*
diff --git a/src/includes/class/class.LSformElement.php b/src/includes/class/class.LSformElement.php
index b74b40f3..321e16e2 100644
--- a/src/includes/class/class.LSformElement.php
+++ b/src/includes/class/class.LSformElement.php
@@ -66,6 +66,15 @@ class LSformElement extends LSlog_staticLoggerClass {
return true;
}
+ /**
+ * Allow conversion of LSformElement to string
+ *
+ * @retval string The string representation of the LSformElement
+ */
+ public function __toString() {
+ return strval($this -> form)." -> <".get_class($this)." ".$this -> name.">";
+ }
+
/**
* Définis la valeur de l'élément
*
diff --git a/src/includes/class/class.LSldapObject.php b/src/includes/class/class.LSldapObject.php
index 27f82610..8deac85c 100644
--- a/src/includes/class/class.LSldapObject.php
+++ b/src/includes/class/class.LSldapObject.php
@@ -1898,15 +1898,32 @@ class LSldapObject extends LSlog_staticLoggerClass {
* @retval string The string representation of the LdapObject
*/
public function __toString() {
+ return $this -> toString(true);
+ }
+
+ /**
+ * Return string representation of the object
+ *
+ * @param[in] $enclosed boolean If true, result will be enclosed using "< >" (optional, default: true)
+ *
+ * @retval string The string representation of the LdapObject
+ */
+ public function toString($enclosed=true) {
+ $str = "LdapObject ".$this -> getType();
if ($this -> dn)
- return " dn.">";
- $rdn_attr = $this -> getConfig('rdn');
- if( $rdn_attr && isset($this -> attrs[$rdn_attr]) ) {
- $rdn_val = $this -> attrs[$rdn_attr] -> getUpdateData();
- if (!empty($rdn_val))
- return "";
+ $str .= " ".$this -> dn;
+ else {
+ $str .= " (new)";
+ $rdn_attr = $this -> getConfig('rdn');
+ if( $rdn_attr && isset($this -> attrs[$rdn_attr]) ) {
+ $rdn_val = $this -> attrs[$rdn_attr] -> getUpdateData();
+ if (!empty($rdn_val))
+ $str .= " $rdn_attr=".$rdn_val[0];
+ }
}
- return "";
+ if ($enclosed)
+ return "<$str>";
+ return $str;
}
/**
diff --git a/src/includes/class/class.LSlog_email.php b/src/includes/class/class.LSlog_email.php
index 81c6b5ce..41611a79 100644
--- a/src/includes/class/class.LSlog_email.php
+++ b/src/includes/class/class.LSlog_email.php
@@ -43,6 +43,19 @@ class LSlog_email extends LSlog_handler {
public function __construct($config) {
parent :: __construct($config);
$this -> recipient = self :: getConfig('recipient');
+ $this -> logging('TRACE', "$this Enabled", get_class($this));
+ }
+
+ /**
+ * Return list of details for the string representation of the LSlog_email
+ *
+ * @retval array List of details for the string representation of the LSlog_email
+ */
+ public function __toStringDetails() {
+ return array_merge(
+ array("recipient=".$this -> recipient),
+ parent :: __toStringDetails(),
+ );
}
/**
diff --git a/src/includes/class/class.LSlog_file.php b/src/includes/class/class.LSlog_file.php
index 64b8fd56..4d72c8fb 100644
--- a/src/includes/class/class.LSlog_file.php
+++ b/src/includes/class/class.LSlog_file.php
@@ -43,6 +43,19 @@ class LSlog_file extends LSlog_handler {
$this -> path = self :: getConfig('path', LSlog :: getConfig('filename', 'tmp/LS.log'));
if (substr($this -> path, 0, 1) != '/')
$this -> path = LS_ROOT_DIR."/".$this -> path;
+ $this -> logging('TRACE', "$this Enabled", get_class($this));
+ }
+
+ /**
+ * Return list of details for the string representation of the LSlog_file
+ *
+ * @retval array List of details for the string representation of the LSlog_file
+ */
+ public function __toStringDetails() {
+ return array_merge(
+ array("path=".$this -> path),
+ parent :: __toStringDetails(),
+ );
}
/**
diff --git a/src/includes/class/class.LSlog_handler.php b/src/includes/class/class.LSlog_handler.php
index 24dda664..bd152fbd 100644
--- a/src/includes/class/class.LSlog_handler.php
+++ b/src/includes/class/class.LSlog_handler.php
@@ -65,6 +65,28 @@ class LSlog_handler {
$this -> excluded_loggers = array($this -> excluded_loggers);
}
+ /**
+ * Allow conversion of LSlog_handler to string
+ *
+ * @retval string The string representation of the LSlog_handler
+ */
+ public function __toString() {
+ return "<".get_class($this)." ".implode(', ', $this -> __toStringDetails()).">";
+ }
+
+ /**
+ * Return list of details for the string representation of the LSlog_handler
+ *
+ * @retval array List of details for the string representation of the LSlog_handler
+ */
+ public function __toStringDetails() {
+ return array(
+ "level=".($this -> level?$this -> level:'default'),
+ "loggers=".($this -> loggers?implode(',', $this -> loggers):'all'),
+ "excluded loggers=".($this -> excluded_loggers?implode(',', $this -> excluded_loggers):'no'),
+ );
+ }
+
/**
* Check system compatibility with this handler
*
diff --git a/src/includes/class/class.LSlog_logger.php b/src/includes/class/class.LSlog_logger.php
index 6b87cec3..d782384a 100644
--- a/src/includes/class/class.LSlog_logger.php
+++ b/src/includes/class/class.LSlog_logger.php
@@ -52,10 +52,17 @@ class LSlog_logger {
$this -> config = $config;
$this -> enabled = $this -> getConfig('enabled', true, 'boolean');
$this -> level = $this -> getConfig('level');
- if ($this -> enabled)
- $this -> debug("Enabled $name logger with level=".$this -> level);
}
+ /**
+ * Allow conversion of LSlog_logger to string
+ *
+ * @retval string The string representation of the LSlog_logger
+ */
+ public function __toString() {
+ return "<".get_class($this)." ".$this -> name.">";
+ }
+
/**
* Get a configuration variable value
*
diff --git a/src/includes/class/class.LSlog_syslog.php b/src/includes/class/class.LSlog_syslog.php
index 37564463..3847aebf 100644
--- a/src/includes/class/class.LSlog_syslog.php
+++ b/src/includes/class/class.LSlog_syslog.php
@@ -59,6 +59,19 @@ class LSlog_syslog extends LSlog_handler {
public function __construct($config) {
parent :: __construct($config);
$this -> priority = static :: getConfig('priority');
+ $this -> logging('TRACE', "$this Enabled", get_class($this));
+ }
+
+ /**
+ * Return list of details for the string representation of the LSlog_email
+ *
+ * @retval array List of details for the string representation of the LSlog_email
+ */
+ public function __toStringDetails() {
+ return array_merge(
+ array("priority=".$this -> priority),
+ parent :: __toStringDetails(),
+ );
}
/**
diff --git a/src/includes/class/class.LSrelation.php b/src/includes/class/class.LSrelation.php
index 8d8eb0a9..061e5076 100644
--- a/src/includes/class/class.LSrelation.php
+++ b/src/includes/class/class.LSrelation.php
@@ -61,6 +61,15 @@ class LSrelation extends LSlog_staticLoggerClass {
}
}
+ /**
+ * Allow conversion of LSrelation to string
+ *
+ * @retval string The string representation of the LSrelation
+ */
+ public function __toString() {
+ return " name." on ".$this -> obj -> toString(false).">";
+ }
+
/**
* Return a configuration parameter (or default value)
*
diff --git a/src/includes/class/class.LSsearch.php b/src/includes/class/class.LSsearch.php
index 5877987a..67d70121 100644
--- a/src/includes/class/class.LSsearch.php
+++ b/src/includes/class/class.LSsearch.php
@@ -115,6 +115,16 @@ class LSsearch extends LSlog_staticLoggerClass {
}
+ /**
+ * Allow conversion of LSsearch to string
+ *
+ * @retval string The string representation of the LSsearch
+ */
+ public function __toString() {
+ $search_params = $this -> formatSearchParams();
+ return " LSobject." (context=".$this -> context.")".($search_params?" $search_params":"").">";
+ }
+
/**
* Load configuration from LSconfig
*
@@ -912,18 +922,18 @@ class LSsearch extends LSlog_staticLoggerClass {
*/
public function run($cache=true) {
$this -> generateSearchParams();
- self :: log_debug("run(".($cache?'with cache':'without cache')."): ".self :: formatSearchParams());
+ self :: log_debug($this." -> run(".($cache?'with cache':'without cache').")");
if( $cache && (!isset($_REQUEST['refresh'])) && (!$this -> params['withoutCache']) ) {
- self :: log_debug('Cache enabled');
+ self :: log_debug($this.' -> run(): Cache enabled');
$this -> result = $this -> getResultFromCache();
if ($this -> result)
- self :: log_debug('result retreived from cache');
+ self :: log_debug($this.' -> run(): result retreived from cache');
else
- self :: log_debug('result not found in cache');
+ self :: log_debug($this.' -> run(): result not found in cache');
}
else {
- self :: log_debug('Cache disabled');
+ self :: log_debug($this.' -> run(): Cache disabled');
$this -> setParam('withoutCache', false);
}
@@ -948,7 +958,7 @@ class LSsearch extends LSlog_staticLoggerClass {
// Handle onlyAccessible parameter
if ($this -> getParam('onlyAccessible') && LSsession :: getLSuserObjectDn()) {
- self :: log_debug('Filter on only accessible object');
+ self :: log_debug($this.' -> run(): Filter on only accessible object');
$this -> result['list'] = array();
// Check user rights on objets
@@ -963,7 +973,7 @@ class LSsearch extends LSlog_staticLoggerClass {
$this -> addResultToCache();
}
- self :: log_debug($this -> total. " object(s) found");
+ self :: log_debug($this.' -> run(): '.$this -> total. " object(s) found");
$this -> doSort();
diff --git a/src/includes/class/class.LSsearchEntry.php b/src/includes/class/class.LSsearchEntry.php
index 5dd714a2..f45dc5cb 100644
--- a/src/includes/class/class.LSsearchEntry.php
+++ b/src/includes/class/class.LSsearchEntry.php
@@ -75,6 +75,15 @@ class LSsearchEntry extends LSlog_staticLoggerClass {
$this -> cache =& $result[$id]['cache'];
}
+ /**
+ * Allow conversion of LSsearchEntry to string
+ *
+ * @retval string The string representation of the LSsearchEntry
+ */
+ public function __toString() {
+ return $this -> LSsearch." -> dn." (ID #".$this -> id.")>";
+ }
+
/**
* Get text value of entry
*