Improvements to debug_log
This commit is contained in:
70
lib/ds.php
70
lib/ds.php
@@ -70,6 +70,9 @@ abstract class DS {
|
||||
* Return a configuration value
|
||||
*/
|
||||
public function getValue($key,$setting,$fatal=true) {
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,1,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (isset($this->custom->{$key}[$setting]))
|
||||
return $this->custom->{$key}[$setting];
|
||||
|
||||
@@ -115,6 +118,9 @@ abstract class DS {
|
||||
* Get the name of this datastore
|
||||
*/
|
||||
public function getName() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
return $this->getValue('server','name');
|
||||
}
|
||||
|
||||
@@ -125,6 +131,9 @@ abstract class DS {
|
||||
* Return the authentication type for this object
|
||||
*/
|
||||
public function getAuthType() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
switch ($this->getValue('login','auth_type')) {
|
||||
case 'config':
|
||||
case 'http':
|
||||
@@ -144,6 +153,9 @@ abstract class DS {
|
||||
* If this returns '', we are logged in with anonymous
|
||||
*/
|
||||
public function getLogin($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$method = $this->getMethod($method);
|
||||
|
||||
# For anonymous binds
|
||||
@@ -182,6 +194,9 @@ abstract class DS {
|
||||
* Set the login details of the user logged into this datastore's connection method
|
||||
*/
|
||||
protected function setLogin($user,$pass,$method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$method = $this->getMethod($method);
|
||||
|
||||
switch ($this->getAuthType()) {
|
||||
@@ -208,6 +223,9 @@ abstract class DS {
|
||||
* Get the login password of the user logged into this datastore's connection method
|
||||
*/
|
||||
protected function getPassword($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$method = $this->getMethod($method);
|
||||
|
||||
# For anonymous binds
|
||||
@@ -241,6 +259,9 @@ abstract class DS {
|
||||
* Return if this datastore's connection method has been logged into
|
||||
*/
|
||||
public function isLoggedIn($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $CACHE = array();
|
||||
|
||||
$method = $this->getMethod($method);
|
||||
@@ -319,6 +340,9 @@ abstract class DS {
|
||||
* Logout of this datastore's connection method
|
||||
*/
|
||||
public function logout($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
$method = $this->getMethod($method);
|
||||
|
||||
unset ($_SESSION['cache'][$this->index]);
|
||||
@@ -344,10 +368,16 @@ abstract class DS {
|
||||
* Functions that return the condition of the datasource
|
||||
*/
|
||||
public function isVisible() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
return $this->getValue('server','visible');
|
||||
}
|
||||
|
||||
public function isReadOnly() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if (! trim($this->getLogin(null)) && $_SESSION[APPCONFIG]->getValue('appearance','anonymous_bind_implies_read_only'))
|
||||
return true;
|
||||
else
|
||||
@@ -355,6 +385,9 @@ abstract class DS {
|
||||
}
|
||||
|
||||
public function getIndex() {
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->index);
|
||||
|
||||
return $this->index;
|
||||
}
|
||||
|
||||
@@ -368,6 +401,9 @@ abstract class DS {
|
||||
* @return string Connection Method
|
||||
*/
|
||||
protected function getMethod($method=null) {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $CACHE = array();
|
||||
|
||||
# Immediately return if method is set.
|
||||
@@ -390,6 +426,9 @@ abstract class DS {
|
||||
* This method should be overridden in application specific ds files
|
||||
*/
|
||||
public function isSessionValid() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs,true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -398,6 +437,9 @@ abstract class DS {
|
||||
* this function will return null.
|
||||
*/
|
||||
public function inactivityTime() {
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
if ($this->isLoggedIn() && ! in_array($this->getAuthType(),array('config','http')))
|
||||
return time()+($this->getValue('login','timeout')*60);
|
||||
else
|
||||
@@ -511,10 +553,6 @@ class Datastore {
|
||||
* Set values for a database object.
|
||||
*/
|
||||
public function setValue($key,$setting,$value) {
|
||||
if (defined('DEBUG_ENABLED') && (DEBUG_ENABLED))
|
||||
debug_log('Entered with (%s,%s,%s)',3,__FILE__,__LINE__,__METHOD__,
|
||||
$key,$setting,$value);
|
||||
|
||||
if (! $this->objects[$this->index]->isDefaultKey($key))
|
||||
error("ERROR: Setting a key [$key] that isnt predefined.",'error',true);
|
||||
|
||||
@@ -539,14 +577,14 @@ class Datastore {
|
||||
* @return array list of all configured servers.
|
||||
*/
|
||||
public function getServerList($isVisible=true) {
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
static $CACHE;
|
||||
|
||||
if (isset($CACHE[$isVisible]))
|
||||
return $CACHE[$isVisible];
|
||||
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$isVisible);
|
||||
|
||||
$CACHE[$isVisible] = array();
|
||||
|
||||
# Debugging incase objects is not set.
|
||||
@@ -560,10 +598,6 @@ class Datastore {
|
||||
if (! $isVisible || ($isVisible && $server->getValue('server','visible')))
|
||||
$CACHE[$isVisible][$id] = $server;
|
||||
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s), Returning (%s)',3,__FILE__,__LINE__,__METHOD__,
|
||||
$isVisible,$CACHE);
|
||||
|
||||
return $CACHE[$isVisible];
|
||||
}
|
||||
|
||||
@@ -574,8 +608,8 @@ class Datastore {
|
||||
* @return object Datastore instance object.
|
||||
*/
|
||||
public function Instance($index=null) {
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$index);
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
# If no index defined, then pick the lowest one.
|
||||
if (is_null($index))
|
||||
@@ -585,7 +619,7 @@ class Datastore {
|
||||
debug_dump_backtrace("Error: Datastore instance [$index] doesnt exist?",1);
|
||||
|
||||
if (defined('DEBUG_ENABLED') && DEBUG_ENABLED)
|
||||
debug_log('Returning instance of database (%s)',3,__FILE__,__LINE__,__METHOD__,$index);
|
||||
debug_log('Returning instance of database (%s)',3,0,__FILE__,__LINE__,__METHOD__,$index);
|
||||
|
||||
return $this->objects[$index];
|
||||
}
|
||||
@@ -597,8 +631,8 @@ class Datastore {
|
||||
* @return object Datastore instance object.
|
||||
*/
|
||||
public function InstanceName($name=null) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$name);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
foreach ($this->getServerList(false) as $index)
|
||||
if ($this->objects[$index]->getName() == $name)
|
||||
@@ -615,8 +649,8 @@ class Datastore {
|
||||
* @return object Datastore instance object.
|
||||
*/
|
||||
public function InstanceId($id=null) {
|
||||
if (DEBUG_ENABLED)
|
||||
debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$id);
|
||||
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
|
||||
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
|
||||
|
||||
foreach ($this->getServerList(false) as $index)
|
||||
if ($this->objects[$index->getIndex()]->getValue('server','id') == $id)
|
||||
|
Reference in New Issue
Block a user