This repository has been archived by the owner on Mar 6, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge back from debug-dev - #27 #26 #25
git-svn-id: https://www.dropr.org/svn/trunk@167 f77b8f78-39ad-454d-97bc-04c3ead53514
- Loading branch information
Soenke Ruempler
committed
Feb 10, 2008
1 parent
e68bc23
commit aec4ef4
Showing
30 changed files
with
194 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,97 @@ | ||
<?php | ||
/** | ||
* dropr main class | ||
* | ||
* - constants | ||
* - logging | ||
* - autoloading | ||
* | ||
* @author Soenke Ruempler <soenke@ruempler.eu> | ||
*/ | ||
class dropr | ||
{ | ||
/** | ||
* The message is processed | ||
*/ | ||
const MESSAGE_PROCESSED = 1; | ||
} | ||
|
||
/** | ||
* Mapping for error-levels | ||
* | ||
* @var array | ||
*/ | ||
private static $errorLevels = array( | ||
LOG_ERR, | ||
LOG_CRIT, | ||
LOG_WARNING, | ||
LOG_INFO, | ||
LOG_DEBUG, | ||
); | ||
|
||
/** | ||
* the current log-level | ||
* | ||
* @var int | ||
*/ | ||
private static $logLevel = LOG_DEBUG; | ||
|
||
/** | ||
* set the log level | ||
* | ||
* @param unknown_type $logLevel | ||
*/ | ||
public static function setLogLevel($logLevel) | ||
{ | ||
self::$logLevel = $logLevel; | ||
} | ||
|
||
/** | ||
* logging for the dropr services. can be | ||
* - syslog for daemons | ||
* - error_log for http processes | ||
* | ||
* currently only syslog is implemented | ||
* | ||
* @param string $message | ||
* @param int $level | ||
*/ | ||
public static function log($message, $level = LOG_INFO) | ||
{ | ||
if ($level <= self::$logLevel) { | ||
syslog($level, $message); | ||
} | ||
} | ||
|
||
public static function autoload($className) | ||
{ | ||
if (strpos($className, 'dropr_') !== 0) { | ||
return; | ||
} | ||
|
||
|
||
$file = substr(str_replace('_', '/', $className), 6) . '.php'; | ||
require self::$classRoot . $file; | ||
} | ||
|
||
private static $classRoot; | ||
|
||
public static function setClassRoot($classRoot) | ||
{ | ||
self::$classRoot = $classRoot; | ||
} | ||
} | ||
|
||
/* | ||
* enable autoloading | ||
*/ | ||
spl_autoload_register(array('dropr', 'autoload')); | ||
|
||
/* | ||
* set the class root path once | ||
*/ | ||
dropr::setClassRoot(realpath(dirname(__FILE__)) . '/'); | ||
|
||
/* | ||
* set the syslog variables | ||
*/ | ||
openlog('dropr', LOG_ODELAY | LOG_PID, LOG_DAEMON); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.