Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Add logging functions to AJXP_Plugin class / put plugin id as log prefix
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
  • Loading branch information
Etienne CHAMPETIER committed Sep 9, 2013
1 parent 6d2fd41 commit 0c607c1
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions core/src/core/classes/class.AJXP_Plugin.php
Expand Up @@ -20,6 +20,14 @@
*/
defined('AJXP_EXEC') or die( 'Access not allowed');

if (!defined('LOG_LEVEL_DEBUG')) {
define("LOG_LEVEL_DEBUG", "Debug");
define("LOG_LEVEL_INFO", "Info");
define("LOG_LEVEL_NOTICE", "Notice");
define("LOG_LEVEL_WARNING", "Warning");
define("LOG_LEVEL_ERROR", "Error");
}

/**
* The basic concept of plugin. Only needs a manifest.xml file.
* @package AjaXplorer
Expand Down Expand Up @@ -676,6 +684,73 @@ public function getDependencies()
{
return $this->dependencies;
}
/**
* Write a debug log with the plugin id as source
* @param string $prefix A quick description or action
* @param array|string $message Variable number of message args (string or array)
* @return void
*/
public function logDebug($prefix, $message = "")
{
if(!class_exists("ConfService")) return ;
if(!ConfService::getConf("SERVER_DEBUG")) return ;
$args = func_get_args();
array_shift($args);
AJXP_Logger::log2(LOG_LEVEL_DEBUG, $this->getId(), $prefix, $args);
}

/**
* Write an info log with the plugin id as source
* @param string $prefix A quick description or action
* @param array|string $message Variable number of message args (string or array)
* @return void
*/
public function logInfo($prefix, $message)
{
$args = func_get_args();
array_shift($args);
AJXP_Logger::log2(LOG_LEVEL_INFO, $this->getId(), $prefix, $args);
}

/**
* Write a notice log with the plugin id as source
* @param string $prefix A quick description or action
* @param array|string $message Variable number of message args (string or array)
* @return void
*/
public function logNotice($prefix, $message)
{
$args = func_get_args();
array_shift($args);
AJXP_Logger::log2(LOG_LEVEL_NOTICE, $this->getId(), $prefix, $args);
}

/**
* Write a warning log with the plugin id as source
* @param string $prefix A quick description or action
* @param array|string $message Variable number of message args (string or array)
* @return void
*/
public function logWarning($prefix, $message)
{
$args = func_get_args();
array_shift($args);
AJXP_Logger::log2(LOG_LEVEL_WARNING, $this->getId(), $prefix, $args);
}

/**
* Write an error log with the plugin id as source
* @param string $prefix A quick description or action
* @param array|string $message Variable number of message args (string or array)
* @return void
*/
public function logError($prefix, $message)
{
$args = func_get_args();
array_shift($args);
AJXP_Logger::log2(LOG_LEVEL_ERROR, $this->getId(), $prefix, $args);
}

/**
* Detect if this plugin declares a StreamWrapper, and if yes loads it and register the stream.
* @param bool $register
Expand Down

0 comments on commit 0c607c1

Please sign in to comment.