/** * * @covers Vatsimphp\VatsimData::prepareSync */ public function testPrepareSync() { $statusSync = $this->getSyncMock('status'); $statusSync->expects($this->once())->method('setDefaults'); $statusSync->expects($this->once())->method('registerUrl')->with($this->equalTo('custom_url'), $this->equalTo(true)); LoggerFactory::$level = Logger::DEBUG; LoggerFactory::$file = null; $data = $this->getDataMock(array('getStatusSync')); $data->setConfig('statusUrl', 'custom_url'); $data->setConfig('logLevel', Logger::CRITICAL); $data->setConfig('logFile', 'test.log'); $data->expects($this->once())->method('getStatusSync')->will($this->returnValue($statusSync)); $prepare = new \ReflectionMethod($data, 'prepareSync'); $prepare->setAccessible(true); $this->assertInstanceOf('Vatsimphp\\Sync\\StatusSync', $prepare->invoke($data)); $this->assertEquals(Logger::CRITICAL, LoggerFactory::$level); $this->assertEquals('test.log', LoggerFactory::$file); }
/** * * Prepare MetarSync object for reusage * @return MetarSync */ protected function prepareMetarSync() { if (!empty($this->metarSync)) { return $this->metarSync; } LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $this->metarSync = $this->getMetarSync(); $this->metarSync->setDefaults(); $this->metarSync->cacheDir = $this->config['cacheDir']; $this->metarSync->cacheOnly = false; $this->metarSync->refreshInterval = $this->config['metarRefresh']; $this->metarSync->forceRefresh = $this->config['forceMetarRefresh']; $this->metarSync->registerUrlFromStatus($this->prepareSync(), 'metarUrls'); return $this->metarSync; }
/** * * Ctor */ public function __construct() { $this->log = LoggerFactory::get($this); $this->cacheDir = __DIR__ . '/../../../app/cache'; }
* you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * Consult the documentation for more details at: * https://github.com/skymeyer/Vatsimphp/tree/master/docs **/ use Vatsimphp\VatsimData; use Vatsimphp\Log\LoggerFactory; use Monolog\Logger; use Monolog\Handler\StreamHandler; require_once '../vendor/autoload.php'; // Create custom logger based on Monolog (note: every PSR-3 compliant logger will work) // see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md $logFile = __DIR__ . '/../app/logs/vatsimphp_custom.log'; $logger = new Logger('vatsimphp'); $logger->pushHandler(new StreamHandler($logFile, Logger::DEBUG)); // Register custom logger LoggerFactory::register("_DEFAULT_", $logger); $vatsim = new VatsimData(); $vatsim->loadData(); // see app/logs/vatsimphp_custom.log for the result
/** * * Ctor */ public function __construct() { $this->results = new ResultContainer(); $this->log = LoggerFactory::get($this); }