public function testGetLoggerInstance() { $Logger1 = PMCLibrary::getLoggerInstance(__CLASS__); $this->assertNotNull($Logger1); $Logger2 = PMCLibrary::getLoggerInstance(__CLASS__); $this->assertSame($Logger1, $Logger2); }
public function testLoggerInstance2() { $obj3 = PMCLibrary::getLoggerInstance(); $this->assertNotSame($this->Logger, $obj3); $obj4 = PMCLibrary::getLoggerInstance('Global'); $this->assertSame($obj3, $obj4); }
/** * 取得 PIO 函式庫物件 * * @return IPIO PIO 函式庫物件 */ public static function getPIOInstance() { global $PIOEnv; static $instPIO = null; if ($instPIO == null) { require ROOTPATH . 'lib/lib_pio.php'; $pioExactClass = 'PIO' . PIXMICAT_BACKEND; $instPIO = new LoggerInjector(new $pioExactClass(CONNECTION_STRING, $PIOEnv), new LoggerInterceptor(PMCLibrary::getLoggerInstance($pioExactClass))); } return $instPIO; }
public function __construct() { $this->LOG = PMCLibrary::getLoggerInstance('AbstractFileIO'); $this->absoluteUrl = $this->getAbsoluteUrl(); $this->cacheFile = $this->getCacheFile(); }
/** * Handles thrown exceptions by program itself or PHP. */ function exceptionHandler($e) { PMCLibrary::getLoggerInstance('Global')->error('Exception caught: %s', $e); }
public function testInstance() { $obj = new LoggerInterceptor(PMCLibrary::getLoggerInstance('Test')); $this->assertNotNull($obj); $this->assertInstanceOf('MethodInterceptor', $obj); }
function openIndex() { if (extension_loaded('pdo_sqlite')) { $this->backend = 'pdo_sqlite'; $this->index = new PDO('sqlite:' . $this->logfile); if ($this->index->query("SELECT COUNT(name) FROM sqlite_master WHERE name LIKE 'IndexFS'")->fetchColumn() === '0') { $this->init(); } } else { if (extension_loaded('SQLite')) { $this->backend = 'sqlite2'; $this->index = sqlite_open($this->logfile, 0666); if (sqlite_num_rows(sqlite_query($this->index, "SELECT name FROM sqlite_master WHERE name LIKE 'IndexFS'")) === 0) { $this->init(); } } else { $this->backend = 'log'; $this->modified = false; if (!file_exists($this->logfile)) { $this->init(); return; } if (filesize($this->logfile) == 0) { return; } $indexlog = file($this->logfile); $indexlog_count = count($indexlog); // 讀入索引檔並計算目前筆數 $this->index = array(); for ($i = 0; $i < $indexlog_count; $i++) { if (!($trimline = rtrim($indexlog[$i]))) { continue; } // 本行無意義 $field = explode("\t\t", $trimline); $this->index[$field[0]] = array('imgSize' => $field[1], 'imgURL' => isset($field[2]) ? $field[2] : ''); // 索引格式: 檔名 檔案大小 對應路徑 } $this->keylist = array_keys($this->index); unset($indexlog); } } PMCLibrary::getLoggerInstance(__CLASS__)->info('Backend: %s, Path: %s', $this->backend, $this->logfile); }
/** * @expectedException InvalidArgumentException */ public function testInstanceInvaildPrincipal() { new LoggerInjector(array(1, 2, 3), new LoggerInterceptor(PMCLibrary::getLoggerInstance('TempClass'))); }