public function run($args) { // $this->logger = LoggerFactory::getFileLogger('ReportSendTest'); $this->logger = LoggerFactory::getConsoleLogger(); // $processedReportsModel = new ScheduleTypeReportProcessed(); // $reports = $processedReportsModel->getUnsentReports(); // // // $reports = $processedReportsModel->findByUIDsWithDestinations($reports['uids']); // // // $this->logger->log(__METHOD__.' reports:'.print_r($reports['result'],1)); // // // foreach ($reports['result'] as $reportItem) { // $this->sendReport($reportItem); // } $scheduleTypeReportSendLog = new ScheduleTypeReportSendLog(); $reports = $scheduleTypeReportSendLog->getUnsentReportItems(); $result = $scheduleTypeReportSendLog->findByUIDsWithDestinations($reports['uids']); foreach ($result['result'] as $reportItem) { $this->sendReport($reportItem); } $this->logger->log(__METHOD__ . ' reports:' . print_r($reports['uids'], 1)); $this->logger->log(__METHOD__ . ' reports:' . print_r($result, 1)); }
public function run($args) { $logger = LoggerFactory::getFileLogger('check_processes'); $logger->log(__METHOD__ . ' Start checkprocesses command.'); $criteria = new CDbCriteria(); $criteria->compare('stopped', 0); $connections = Listener::model()->findAll($criteria); $logger->log(__METHOD__ . ' Found ' . count($connections) . ' connections.'); foreach ($connections as $connection) { $logger->log(__METHOD__ . ' Listener info:', array('process_pid' => $connection->process_pid, 'listener_id' => $connection->listener_id, 'source' => $connection->source)); if (ProcessPid::isActiveProcess($connection->process_pid) === false) { ListenerProcess::addComment($connection->listener_id, 'comment', 'System found out that process is not active any more. Process will be re-run right now.'); Listener::stopConnection($connection->listener_id, time()); Listener::runConnection($connection->source, $connection->additional_param, 'auto'); } } // ProcessPid::killProcess(12376); $synchronization = new Synchronization(); if ($synchronization->isProcessed() && ProcessPid::isActiveProcess($synchronization->getTcpServerPid()) === false) { $synchronization->startTcpServer(); } if ($synchronization->isProcessed() && ProcessPid::isActiveProcess($synchronization->getTcpClientPid()) === false) { $synchronization->startTcpClient(); } }
/** * Ini system param */ public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); $this->_logger = LoggerFactory::getFileLogger('process_sync_db'); }
/** * Initializes logger at first call. * * @return ILogger */ protected static function getLogger() { if (is_null(self::$_logger)) { self::$_logger = LoggerFactory::getFileLogger('prepare_message'); } return self::$_logger; }
/** * @param $msg * @param $listener_id * @param $rewrite_prev_values * @param string $source * @param int $station_id * @param null $source_info * @return int * @var $synchronization Synchronization */ public static function addNew($msg, $listener_id, $rewrite_prev_values, $source = '', $station_id = 0, $source_info = null) { $synchronization = new Synchronization(); $listener_id_from_master = $synchronization->getListenerId(); $parseMessage = new ParseMessage(LoggerFactory::getFileLogger('parse_message'), $msg); $message_obj = new ListenerLogTemp(); $message_obj->listener_id = $listener_id; $message_obj->station_id_code = $parseMessage->getStationIdCode(); $message_obj->message = $msg; $message_obj->measuring_timestamp = $parseMessage->getMeasuringTimestamp(); $message_obj->is_processed = 0; $message_obj->is_processing = 0; if ($listener_id_from_master === $listener_id and $listener_id != 0) { $message_obj->from_master = 1; } else { $message_obj->from_master = 0; } $message_obj->source = $source; $message_obj->source_info = $source_info; if ($synchronization->isProcessed()) { $message_obj->synchronization_mode = $synchronization->isMaster() ? 'master' : ($synchronization->isSlave() ? 'slave' : 'none'); } else { $message_obj->synchronization_mode = 'none'; } $message_obj->rewrite_prev_values = $rewrite_prev_values; $message_obj->save(); return $message_obj->temp_log_id; }
protected static function createConnector() { $logger = LoggerFactory::getTestLogger(); //return new TcpClientConnector($logger, 'tcp', '192.168.101.212', '1040'); //return new TcpClientConnector($logger, 'tcp', 'localhost', '89'); return new TcpClientConnector($logger, 'tcp', '192.168.101.191', '1039'); }
private function __construct() { $this->processedReportsModel = new ScheduleTypeReportProcessed(); $this->synchronization = new Synchronization(); $this->_logger = LoggerFactory::getFileLogger('ExchangeODSS'); TimezoneWork::set('UTC'); }
public function init() { // create logger self::$_logger = LoggerFactory::getInstance(ucfirst($this->{FrameworkConstants::ENTITY_NAME}) . 'ActiveRecord'); // load database configs $file = $this->{FrameworkConstants::DATABASE_CONFIG_FILE}; $configSection = $this->{FrameworkConstants::DATABASE_CONFIG_SECTION}; if (!is_file($file)) { throw new Exception("Can't find database config file (" . $file . ")..."); } self::$_logger->debug('Looking for db section -> ' . $configSection); $configData = IniParser::parse($file, $configSection); $data = $configData[$configSection]; $this->{FrameworkConstants::DATABASE_TYPE} = $data[FrameworkConstants::DATABASE_TYPE]; $this->{FrameworkConstants::DATABASE_HOST} = $data[FrameworkConstants::DATABASE_HOST]; $this->{FrameworkConstants::DATABASE_NAME} = $data[FrameworkConstants::DATABASE_NAME]; $this->{FrameworkConstants::DATABASE_USERNAME} = $data[FrameworkConstants::DATABASE_USERNAME]; $this->{FrameworkConstants::DATABASE_PASSWORD} = $data[FrameworkConstants::DATABASE_PASSWORD]; $this->{FrameworkConstants::MYSQL_COMMAND} = $data[FrameworkConstants::MYSQL_COMMAND]; $this->{FrameworkConstants::MYSQL_COMMAND_CONTINUE_ON_ERROR} = $data[FrameworkConstants::MYSQL_COMMAND_CONTINUE_ON_ERROR]; $this->_currentDataSourceName = $this->{FrameworkConstants::DATABASE_CONFIG_SECTION}; $this->_returnErrors = $this->{FrameworkConstants::RETURN_ERRORS}; // Load table info $this->getTableInfo(); }
public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); $this->_logger = LoggerFactory::getFileLogger('sms'); // $this->_logger = LoggerFactory::getConsoleLogger(); }
public function __construct() { // create logger self::$_logger = LoggerFactory::getInstance(get_class(), self::LOG_FILE_NAME); // initialize self::_init(); // resolve url mapper self::_resolve(); }
function __construct() { $this->_init($this->_TABLE_NAME); $this->_dbServer = DB_SERVER; $this->_dbName = DB_NAME; $this->_username = DB_USERNAME; $this->_password = DB_PASSWORD; self::$logger = LoggerFactory::getInstance(get_class()); }
public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); self::$_logger = LoggerFactory::getFileLogger('reports'); // All reports are generated basing on data in UTC time. TimezoneWork::set('UTC'); }
public function test_PrepareDataPairs_EmptyValues() { $handler = new CloudHeightAWSSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = 'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'cloud_height_height_1', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_depth_1', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_height_2', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_depth_2', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_height_3', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_height_depth_3', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_vertical_visibility', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1), array('feature_code' => 'cloud_measuring_range', 'period' => 1, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function test_PrepareDataPairs_WithCloudAmounts_SomeEmptyValues() { $handler = new CloudHeightAwsDlm13mSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = 's66551234567890543210987632154879601000050000-100350,//////,304350,//////,7-'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'status', 'period' => 1, 'value' => '6655', 'metric_id' => null, 'normilized_value' => '6655', 'is_m' => 0), array('feature_code' => 'cloud_height_height_1', 'period' => 1, 'value' => '12345', 'metric_id' => null, 'normilized_value' => '12345', 'is_m' => 0), array('feature_code' => 'cloud_height_depth_1', 'period' => 1, 'value' => '67890', 'metric_id' => null, 'normilized_value' => '67890', 'is_m' => 0), array('feature_code' => 'cloud_height_height_2', 'period' => 1, 'value' => '54321', 'metric_id' => null, 'normilized_value' => '54321', 'is_m' => 0), array('feature_code' => 'cloud_height_depth_2', 'period' => 1, 'value' => '09876', 'metric_id' => null, 'normilized_value' => '09876', 'is_m' => 0), array('feature_code' => 'cloud_height_height_3', 'period' => 1, 'value' => '32154', 'metric_id' => null, 'normilized_value' => '32154', 'is_m' => 0), array('feature_code' => 'cloud_height_depth_3', 'period' => 1, 'value' => '87960', 'metric_id' => null, 'normilized_value' => '87960', 'is_m' => 0), array('feature_code' => 'cloud_vertical_visibility', 'period' => 1, 'value' => '10000', 'metric_id' => null, 'normilized_value' => '10000', 'is_m' => 0), array('feature_code' => 'cloud_measuring_range', 'period' => 1, 'value' => '50000', 'metric_id' => null, 'normilized_value' => '50000', 'is_m' => 0), array('feature_code' => 'cloud_amount_amount_1', 'period' => 30, 'value' => '1', 'metric_id' => null, 'normilized_value' => '1', 'is_m' => 0), array('feature_code' => 'cloud_amount_height_1', 'period' => 30, 'value' => '350', 'metric_id' => null, 'normilized_value' => '350', 'is_m' => 0), array('feature_code' => 'cloud_amount_amount_2', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_height_2', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_amount_3', 'period' => 30, 'value' => '3', 'metric_id' => null, 'normilized_value' => '3', 'is_m' => 0), array('feature_code' => 'cloud_amount_height_3', 'period' => 30, 'value' => '04350', 'metric_id' => null, 'normilized_value' => '04350', 'is_m' => 0), array('feature_code' => 'cloud_amount_amount_4', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_height_4', 'period' => 30, 'value' => '', 'metric_id' => null, 'normilized_value' => '', 'is_m' => 1), array('feature_code' => 'cloud_amount_amount_total', 'period' => 30, 'value' => '7', 'metric_id' => null, 'normilized_value' => '7', 'is_m' => 0)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function init() { parent::init(); ini_set('memory_limit', '-1'); ini_set('display_errors', '1'); set_time_limit(0); error_reporting(E_ALL); $this->_logger = LoggerFactory::getFileLogger('poller'); // $this->_logger = LoggerFactory::getConsoleLogger(); // For testing }
public function test_PrepareDataPairs_Empty1minAverage_TakeValueFromExtinctionCoeff() { $handler = new VisibilityAwsDlm13mSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = 'MMMMM16060M001.00-ERR-'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'extinction', 'period' => 1, 'value' => '001.00', 'metric_id' => null, 'normilized_value' => '001.00', 'is_m' => 0), array('feature_code' => 'visibility_1', 'period' => 1, 'value' => 3.0, 'metric_id' => null, 'normilized_value' => 3.0, 'is_m' => 1), array('feature_code' => 'visibility_10', 'period' => 10, 'value' => '16060', 'metric_id' => null, 'normilized_value' => '16060', 'is_m' => 0), array('feature_code' => 'status', 'period' => 1, 'value' => 'ERR', 'metric_id' => null, 'normilized_value' => 'ERR', 'is_m' => 0)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
/** * Превращаем объект в колбэк. * @param array $record * @return array */ function __invoke($record) { if (!isset($record['context'])) { $record['context'] = []; } foreach (LoggerFactory::getGlobalContext() as $k => $v) { $record['context'][$k] = $v; } return $record; }
public function test_PrepareDataPair_Empty10minAverage() { $handler = new VisibilityAWSSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = '16106MMMMMMMMMMMMMM'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'visibility_1', 'period' => 1, 'value' => '16106', 'metric_id' => null, 'normilized_value' => '16106', 'is_m' => 0), array('feature_code' => 'visibility_10', 'period' => 10, 'value' => 'MMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMM', 'is_m' => 1)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function test_PrepareDataPair_EmptySnowDepth() { $handler = new SnowDepthAwsDlm13mSensorHandler(LoggerFactory::getTestLogger()); $handler->incoming_sensor_value = '14MMMMMMMM'; $handler->sensor_features_info = array(); $this->assertTrue($handler->_prepareDataPairs()); $expected = array(array('feature_code' => 'snow_depth', 'period' => 1, 'value' => 'MMMMMMMM', 'metric_id' => null, 'normilized_value' => 'MMMMMMMM', 'is_m' => 1), array('feature_code' => 'error_code', 'period' => 1, 'value' => '14', 'metric_id' => null, 'normilized_value' => '14', 'is_m' => 0)); $this->assertEquals(count($expected), count($handler->prepared_pairs)); $this->assertEquals($expected, $handler->prepared_pairs); }
public function run($args) { $this->logger = LoggerFactory::getFileLogger('scheduleReports'); // $this->logger = LoggerFactory::getConsoleLogger(); new ScheduleReports($this->logger, $args); if (!Yii::app()->mutex->lock('ScheduleTypeReports', 3600)) { Yii::app()->end(); } $this->logger = LoggerFactory::getFileLogger('typesReports'); new ScheduleTypeReports($this->logger, $args); Yii::app()->mutex->unlock(); }
function __construct($module = false, $controllerName = false, $renderer = false) { $this->setView($module, $controllerName, $renderer); self::$_logger = LoggerFactory::getInstance(get_class()); if (!$this->_model) { $this->_model = new Model(); } $this->_currentController = $controllerName; $this->_currentModule = $module; $this->_renderer = $renderer; $this->_modelName = StringUtilHelper::underscore($controllerName) . 's'; }
public function testConnect_NoErrors() { $logger = LoggerFactory::getFileLogger('tests/LoggerSerialConnectorTest'); $serial = new PhpSerial($logger); $connector = new DataLoggerSerialConnector(new StubLogger(), $serial); $connector->setParams(array('port' => 'COM1', 'timeout' => 60, 'flowControl' => 'xon/xoff', 'baudrate' => 9600, 'parity' => 'none', 'stopBits' => 1, 'dataBits' => 8)); $output = null; $result = $connector->readData($output); $this->assertTrue($result); $this->assertTrue(count($output) > 0); $this->assertStringMatchesFormat('@DAWS%s$', $output[0]); $errors = $connector->errors(); $this->assertEquals(0, count($errors)); }
public function run($args) { if (empty($args[0])) { exit; } $logger = LoggerFactory::getFileLogger('listener/' . $args[0]); // $logger = LoggerFactory::getConsoleLogger(); $logger->log(__METHOD__ . ' args:' . print_r($args, 1)); // creates object of ProcessListen class, which duty is listening try { (new ProcessListen($logger, $args[0], $args[1], $args[2]))->run(); } catch (Exception $e) { It::sendLetter(Yii::app()->params['developer_email'], 'Problem', $e->getMessage()); } }
public function testConnect_NoErrors() { $logger = LoggerFactory::getFileLogger('tests/RealGsmModemSerialConnectorTest'); $serial = new PhpSerial($logger); $connector = new GsmModemSerialConnector(new StubLogger(), $serial); $connector->setParams(array('port' => 'COM1', 'timeout' => 5, 'flowControl' => 'rts/cts', 'baudrate' => 9600, 'parity' => 'none', 'stopBits' => 1, 'dataBits' => 8)); $output = null; $result = $connector->readData($output); $this->assertTrue($result); $errors = $connector->errors(); $this->assertEquals(0, count($errors)); $this->assertEquals(2, count($output)); $this->assertEquals('AT+CMGL="ALL"', $output[0]); $this->assertEquals('OK', $output[1]); }
/** * Ini system param */ public function init() { parent::init(); ini_set('memory_limit', '-1'); set_time_limit(0); error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); $this->_synchronization = new Synchronization(); $this->_logger = LoggerFactory::getFileLogger('TcpClientCommand'); // $this->_logger = LoggerFactory::getConsoleLogger(); if (Synchronization::setTcpClientPid(getmypid())) { $this->_logger->log(__METHOD__ . ' ' . 'process can take pid = ' . getmypid()); } else { $this->_logger->log(__METHOD__ . ' ' . 'process can not take pid.'); } }
public function __construct($synchronizationObject, $synchronizationRSMObject) { $this->_logger = LoggerFactory::getFileLogger('SynchronizationSwitcher'); $this->_synchronization = $synchronizationObject; $this->_synchronizationRSM = $synchronizationRSMObject; if ($this->_synchronizationRSM->hasServerAnswer()) { if ($this->_synchronization->isFixedSwitchVariant()) { $this->_fixedSwitchLogic(); } if ($this->_synchronization->isFlexibilitySwitchVariant()) { $this->_flexibilitySwitchLogic(); } } else { $this->_synchronization->setInMaster(); } }
public function __construct($renderer = false, $currentModuleName = false, $currentControllerName = false) { $currentTemplateDir = $renderer->getCurrentTemplateDir(); $this->_currentModuleName = $currentModuleName; $this->_currentControllerName = $currentControllerName; $this->_renderer = $renderer; $isGlobal = $renderer->getAttribute(IS_TEMPLATE_GLOBAL); if ($isGlobal == true) { // overide template directory to global $currentTemplateDir = BASE_APPLICATION_DIR . 'global_templates/'; } $this->config(GLOBAL_TEMPLATE_DIR, $currentTemplateDir, DEFAULT_HEADER, DEFAULT_FOOTER); if (method_exists($this, 'setLogger')) { $this->setLogger(); } else { self::$_logger = LoggerFactory::getInstance(get_class()); } }
public function run($args) { ini_set('display_errors', 1); $this->_logger = LoggerFactory::getFileLogger('SendMessageFromFile'); //$this->_logger = LoggerFactory::getConsoleLogger(); $this->_logger->log(__METHOD__, array('args' => $args)); if (count($args) < 3) { $this->_logger->log(__METHOD__ . ' Too few params.'); echo 'Expected 3 parameters: [IP ADDRESS: XXX.XXX.XXX.XXX], [PORT: XXXXX], [FILENAME: XXXXXX]'; exit; } $this->remote_server_ip = $args[0]; $this->remote_server_port = $args[1]; $this->file_name = __DIR__ . '/../../www/files/temp/' . $args[2]; $this->_logger->log(__METHOD__ . ' ' . __DIR__); $this->_logger->log(__METHOD__ . 'filename ' . $this->file_name); $this->readFile(); $this->sendMessage(); }
public static function create($handler_id, $logger = null) { $client_code = Yii::app()->params['client_code']; $class = "{$handler_id}WeatherTypeReport"; $client_class = "{$client_code}{$handler_id}WeatherTypeReport"; if (class_exists($client_class)) { if (is_null($logger)) { $logger = LoggerFactory::getFileLogger($client_class); } return new $client_class($logger); } if (!class_exists($class)) { return false; } if (is_null($logger)) { $logger = LoggerFactory::getFileLogger('typesReports'); } return new $class($logger); }
public function run($args) { if (Yii::app()->mutex->lock('prepare', 300)) { ini_set('memory_limit', '-1'); set_time_limit(0); error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); $this->synchronization = new Synchronization(); $this->_logger = LoggerFactory::getFileLogger('process_message'); // $this->_logger = LoggerFactory::getConsoleLogger(); if ($this->synchronization->isProcessed()) { $this->_logger->log(__METHOD__ . ' synchronization in process'); $this->run_process(); } else { $this->_logger->log(__METHOD__ . ' synchronization stopped'); $this->run_process_base(); } Yii::app()->mutex->unlock(); } }