本文整理汇总了PHP中log::add方法的典型用法代码示例。如果您正苦于以下问题:PHP log::add方法的具体用法?PHP log::add怎么用?PHP log::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log
的用法示例。
在下文中一共展示了log::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* 获取实例
*
* @return void
* @author seatle <seatle@foxmail.com>
* @created time :2016-04-10 22:55
*/
public static function init()
{
if (extension_loaded('Redis')) {
$_instance = new Redis();
} else {
$errmsg = "extension redis is not installed";
log::add($errmsg, "Error");
return null;
}
// 这里不能用pconnect,会报错:Uncaught exception 'RedisException' with message 'read error on connection'
$_instance->connect($GLOBALS['config']['redis']['host'], $GLOBALS['config']['redis']['port'], $GLOBALS['config']['redis']['timeout']);
// 验证
if ($GLOBALS['config']['redis']['pass']) {
if (!$_instance->auth($GLOBALS['config']['redis']['pass'])) {
$errmsg = "Redis Server authentication failed!!";
log::add($errmsg, "Error");
return null;
}
}
// 不序列化的话不能存数组,用php的序列化方式其他语言又不能读取,所以这里自己用json序列化了,性能还比php的序列化好1.4倍
//$_instance->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); // don't serialize data
//$_instance->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); // use built-in serialize/unserialize
//$_instance->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // use igBinary serialize/unserialize
$_instance->setOption(Redis::OPT_PREFIX, $GLOBALS['config']['redis']['prefix'] . ":");
return $_instance;
}
示例2: runDeamon
public static function runDeamon()
{
if (!file_exists('/opt/homebridge/config.json')) {
$response = array();
$platform = array();
$response['description'] = "Configuration Jeedom";
$platform['platform'] = "Jeedom";
$platform['name'] = "Jeedom";
$platform['jeedom_ip'] = "127.0.0.1";
$platform['jeedom_port'] = config::byKey('internalPort');
$platform['jeedom_url'] = config::byKey('internalComplement');
$platform['jeedom_api_key'] = config::byKey('api');
$response['platforms'] = array();
$response['platforms'][] = $platform;
$response['accessories'] = array();
$fp = fopen('/opt/homebridge/config.json', 'w');
fwrite($fp, json_encode($response));
fclose($fp);
}
log::add('homebridge', 'info', 'Lancement du démon homebridge');
$cmd = 'nice -n 19 /usr/bin/nodejs /opt/homebridge/app.js';
log::add('homebridge', 'info', 'Lancement démon homebridge : ' . $cmd);
$result = exec('nohup ' . $cmd . ' >> ' . log::getPathToLog('homebridge') . ' 2>&1 &');
if (!self::deamonRunning()) {
sleep(10);
if (!self::deamonRunning()) {
log::add('homebridge', 'error', 'Impossible de lancer le démon homebridge', 'unableStartDeamon');
return false;
}
}
message::removeAll('homebridge', 'unableStartDeamon');
log::add('homebridge', 'info', 'Démon homebridge lancé');
}
示例3: postNextTopStory
function postNextTopStory()
{
// only post one story every three hours
$tstamp = $this->statusObj->getState('lastTwitterPost');
if (!isset($_GET['test']) and time() - $tstamp < 60 * TWITTER_INTERVAL_MINUTES) {
return;
}
//echo 'continuing';
require_once PATH_CORE . '/classes/content.class.php';
$cObj = new content($this->db);
require_once PATH_CORE . '/classes/log.class.php';
$logObj = new log($this->db);
$topStories = $cObj->fetchUpcomingStories();
$uid = 1;
while ($data = $this->db->readQ($topStories)) {
if (!$this->checkLog($uid, $data->siteContentId) and $data->score >= TWITTER_SCORE_THRESHOLD) {
// post to twitter
$result = $this->update($data->siteContentId, $data->title);
if ($result) {
$logItem = $logObj->serialize(0, $uid, 'postTwitter', $data->siteContentId);
$logObj->add($logItem);
$this->statusObj->setState('lastTwitterPost', time());
}
// only do one at a time
return;
}
}
}
示例4: openzwave_update
function openzwave_update()
{
if (openzwave::deamonRunning()) {
echo 'Stop zwave network...';
openzwave::stopDeamon();
echo "OK\n";
}
echo 'Stop cron...';
$cron = cron::byClassAndFunction('openzwave', 'pull');
if (config::byKey('jeeNetwork::mode') != 'slave') {
if (!is_object($cron)) {
$cron = new cron();
}
$cron->setClass('openzwave');
$cron->setFunction('pull');
$cron->setEnable(1);
$cron->setDeamon(1);
$cron->setDeamonSleepTime(0.5);
$cron->setTimeout(1440);
$cron->setSchedule('* * * * *');
$cron->save();
$cron->stop();
} else {
if (is_object($cron)) {
$cron->remove();
}
}
echo "OK\n";
echo 'Check zwave system...';
if (count(eqLogic::byType('zwave')) > 0) {
log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576');
}
if (config::byKey('port', 'openzwave', 'none') != 'none') {
if (method_exists('openzwave', 'getVersion')) {
if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) {
if (jeedom::getHardwareName() == 'Jeedomboard') {
config::save('allowStartDeamon', 0, 'openzwave');
openzwave::updateOpenzwave(false);
config::save('allowStartDeamon', 1, 'openzwave');
} else {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
}
}
if (config::byKey('jeeNetwork::mode') == 'master') {
foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) {
try {
if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') {
if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
} catch (Exception $e) {
}
}
}
echo "OK\n";
}
示例5: logHourlyStats
function logHourlyStats()
{
require_once PATH_CORE . '/classes/log.class.php';
$logObj = new log($this->db);
// record recentSessions
$q = $this->db->query("SELECT count(id) as cnt FROM fbSessions WHERE fb_sig_time>=date_sub(NOW(), INTERVAL 10 MINUTE);");
$data = $this->db->readQ($q);
$cnt = $data->cnt;
$logItem = $logObj->serialize(0, 0, 'sessionsRecent', $cnt);
$logObj->add($logItem);
// record sessions in last hour
$q = $this->db->query("SELECT count(id) as cnt FROM fbSessions WHERE fb_sig_time>=date_sub(NOW(), INTERVAL 60 MINUTE);");
$data = $this->db->readQ($q);
$cnt = $data->cnt;
$logItem = $logObj->serialize(0, 0, 'sessionsHour', $cnt);
$logObj->add($logItem);
}
示例6: openzwave_update
function openzwave_update()
{
log::add('openzwave', 'error', __('Après toute installation/mise à jour pensez bien à mettre à jour les dépendances Openzwave (voir documentation)', __FILE__));
if (!file_exists(dirname(__FILE__) . '/../data')) {
mkdir(dirname(__FILE__) . '/../data');
}
shell_exec('cp -R /opt/python-openzwave/xml_backups ' . dirname(__FILE__) . '/../data');
shell_exec('cp -R /opt/python-openzwave/zwcfg_*.xml ' . dirname(__FILE__) . '/../data');
shell_exec('rm -rf /opt/python-openzwave/xml_backups');
shell_exec('rm -rf /opt/python-openzwave/zwcfg_*.xml');
config::save('allowStartDeamon', 0, 'openzwave');
echo 'Stop zwave network...';
openzwave::stop();
openzwave::stopDeamon();
echo "OK\n";
echo 'Stop cron...';
$cron = cron::byClassAndFunction('openzwave', 'pull');
if (is_object($cron)) {
$cron->remove();
}
echo "OK\n";
echo 'Check zwave system...';
if (count(eqLogic::byType('zwave')) > 0) {
log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576');
}
if (config::byKey('port', 'openzwave', 'none') != 'none') {
if (method_exists('openzwave', 'getVersion')) {
if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) {
if (jeedom::getHardwareName() == 'Jeedomboard') {
openzwave::updateOpenzwave(false);
} else {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
}
}
if (config::byKey('jeeNetwork::mode') == 'master') {
foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) {
try {
if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') {
if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
} catch (Exception $e) {
}
}
}
echo "OK\n";
echo 'Redemarrage zwave network...';
try {
config::save('allowStartDeamon', 1, 'openzwave');
openzwave::runDeamon();
} catch (Exception $e) {
}
echo "OK\n";
}
示例7: indexAction
public function indexAction()
{
try {
echo "\r\n <br /> hello, i'm indexAction in controller_index, nice 2 meet u! <br />\r\n ";
echo "\r\n <br /> now set language to zh-cn! <br />\r\n ";
i18n::setLanguage('en-us');
echo "\r\n <br /> in english, my name is: " . i18n::get('author') . " <br />\r\n ";
echo "\r\n <br /> now set language to zh-cn! <br />\r\n ";
i18n::setLanguage('zh-cn');
echo "\r\n <br /> in chinese, my name is: " . i18n::get('author') . " <br />\r\n ";
$mDemo = new model_demo();
$uin = 10000;
$uinfo = $mDemo->getUserInfo($uin);
$uinfo2 = $mDemo->getUserInfo2($uin);
$update = $mDemo->updateInfo(6, 1);
var_dump($uinfo, $uinfo2, $update);
$confs = array('title' => 'page title', 'time' => date('Ymd H:i:s'), 'name' => 'ricolau');
log::add('error', 'im test~!');
} catch (exception_i18n $e) {
//i18n 的异常,一般是由于语言包不存在
$code = $e->getCode();
if ($code == exception_i18n::type_language_not_exist) {
echo "\r\n <br /> exception: language of " . i18n::getLanguage() . ' not exist!\\r\\n <br />';
}
echo $e->getMessage();
} catch (Exception $e) {
//如果实在还是有exception,那就捕捉到这里吧,ignore 忽略处理的话。代码继续执行 $this->render(),不会白页。
//throw $e; //如果把这个异常抛上去,当前页面就木有了,上层接收到的话自己处理就好了,比如报个异常啥的
$code = $e->getCode();
echo $e->getMessage();
}
//一般来说 render 这块儿可以不用 try 和 cache,只有 template 或 slot 不存在才会有异常而已。
//但是建议和上面部分业务代码的try cache 结构分离,从而可以更好的决定,如果业务数据有问题,页面是否还继续render()
try {
//按变量单独 assign
$this->assign('uinfo', $uinfo);
$this->assign('updateresult', $update);
//批量assign 一个数组可以!
$this->massign($confs);
$this->render();
} catch (exception_render $e) {
//一般来说这个exception 不会有,模板放好了就行了么
$code = $e->getCode();
if ($code == exception_render::type_tpl_not_exist) {
echo '\\r\\n <br /> exception: template not exist!\\r\\n <br />';
} elseif ($code == exception_render::type_slot_not_exist) {
echo '\\r\\n <br /> exception: template not exist!\\r\\n <br />';
}
echo $e->getMessage();
}
// equals to $this->render('index', 'index');
return;
//绝对不要用 exit!!!!!
}
示例8: getDisplayIds
public static function getDisplayIds($pebbleId)
{
$displayIds = '';
foreach (eqLogic::byType('jebble') as $jebble) {
if ($jebble->getIsEnable() && $jebble->getId() == $pebbleId) {
$displayIds = $jebble->getConfiguration('display_ids');
log::add('jebble', 'debug', 'ids:' . $displayIds);
break;
}
}
return $displayIds;
}
示例9: cron30
public static function cron30($_eqlogic_id = null)
{
if ($_eqlogic_id !== null) {
$eqLogics = array(eqLogic::byId($_eqlogic_id));
} else {
$eqLogics = eqLogic::byType('wazeintime');
sleep(rand(0, 120));
}
foreach ($eqLogics as $wazeintime) {
if ($wazeintime->getIsEnable() == 1) {
try {
$start = $wazeintime->getPosition('start');
$end = $wazeintime->getPosition('end');
$row = $wazeintime->getConfiguration('NOA') ? '' : 'row-';
$wazeRouteurl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&to=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
$request_http = new com_http($wazeRouteurl);
$request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
$json = json_decode($request_http->exec(6, 2), true);
if (isset($json['error'])) {
throw new Exception($json['error']);
}
$data = self::extractInfo($json);
$wazeRoutereturl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&to=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
$request_http = new com_http($wazeRoutereturl);
$request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
$json = json_decode($request_http->exec(6, 2), true);
if (isset($json['error'])) {
throw new Exception($json['error']);
}
$data = array_merge($data, self::extractInfo($json, 'ret'));
log::add('wazeintime', 'debug', 'Data : ' . print_r($data, true));
foreach ($wazeintime->getCmd('info') as $cmd) {
if ($cmd->getLogicalId() == 'lastrefresh') {
$cmd->event(date('H:i'));
continue;
}
if (!isset($data[$cmd->getLogicalId()])) {
continue;
}
if ($cmd->formatValue($data[$cmd->getLogicalId()]) != $cmd->execCmd()) {
$cmd->setCollectDate('');
$cmd->event($data[$cmd->getLogicalId()]);
}
}
$wazeintime->refreshWidget();
} catch (Exception $e) {
log::add('wazeintime', 'error', $e->getMessage());
}
}
}
}
示例10: gCalendar_remove
function gCalendar_remove()
{
$cron = cron::byClassAndFunction('gCalendar', 'pull');
if (is_object($cron)) {
$cron->remove();
}
// supprimer les fichiers cache et le répertoire //
array_map('unlink', glob(GCALENDAR_CACHE_PATH . "gCalendar_*.tmp.xml"));
if (rmdir(GCALENDAR_CACHE_PATH) === true) {
log::add('gCalendar', 'info', 'gCalendar_remove(): Le répertoire (' . GCALENDAR_CACHE_PATH . ') et ses fichiers ont correctement été supprimés.');
} else {
log::add('gCalendar', 'error', 'gCalendar_remove(): Impossible de supprimer le répertoire: ' . GCALENDAR_CACHE_PATH);
}
}
示例11: cron
public static function cron()
{
$now = date('Y-m-d H:i:s', strtotime('-1 second', strtotime(date('Y-m-d H:i:s'))));
$lastDatetime = cache::byKey('sarah::lastRetrievalInternalEvent', $now);
foreach (internalEvent::getNewInternalEvent('sarah') as $internalEvent) {
if (in_array($internalEvent->getEvent(), array('update::interactQuery'))) {
foreach (sarah::byType('sarah') as $sarah) {
if ($sarah->ping()) {
log::add('sarah', 'info', 'Mise à jour de la grammaire de Sarah');
$sarah->updateSrvSarah();
} else {
cache::save('sarah::lastRetrievalInternalEvent', $lastDatetime, 0);
}
}
}
}
}
示例12: failed
public static function failed()
{
$connection = connection::byIp(getClientIp());
if (!is_object($connection)) {
$connection = new connection();
$connection->setIp(getClientIp());
}
$connection->setFailure($connection->getFailure() + 1);
$connection->setStatus('Failed');
if ($connection->getFailure() > config::byKey('security::retry') && strtotime($connection->getDatetime()) + 60 * config::byKey('security::backlogtime') > strtotime('now') && !$connection->isProtect()) {
$connection->setStatus('Ban');
log::add('connection', 'error', __('Attention tentative d\'intrusion détectée venant de l\'IP : ', __FILE__) . $connection->getIp());
}
try {
$connection->save();
} catch (Exception $e) {
}
}
示例13: cron
public static function cron($_eqlogic_id = null, $force = false)
{
if ($_eqlogic_id !== null) {
$eqLogics = array(eqLogic::byId($_eqlogic_id));
} else {
$eqLogics = eqLogic::byType('trains');
}
foreach ($eqLogics as $trains) {
if ($trains->getIsEnable() == 1) {
if ($force || date('Hi', time()) >= $trains->getConfiguration('trains_maj_deb') && date('Hi', time()) <= $trains->getConfiguration('trains_maj_fin')) {
log::add('trains', 'debug', 'Pull ' . ($force ? 'Forcé' : 'Cron') . ' pour trains ');
$baseUrl = 'http://www.gares-sncf.com/fr/train-times/departure/' . $trains->getConfiguration('trains_depart') . '/gl';
$arrivee = $trains->getConfiguration('trains_arrivee');
$response = file_get_contents($baseUrl);
$json = json_decode($response, true);
$departs = [];
foreach ($json['trains'] as $depart) {
$trainCourant = (object) [];
if ($arrivee == '' || $trains->string_contains($depart['origdest'], $arrivee)) {
$trainCourant->dest = $depart['origdest'];
$trainCourant->type = $depart['type'];
$trainCourant->voie = $depart['voie'];
$trainCourant->heure = $depart['heure'];
$trainCourant->etat = $depart['etat'];
$trainCourant->retard = $depart['retard'];
$trainCourant->infos = $depart['infos'];
$departs[] = $trainCourant;
}
}
log::add('trains', 'debug', 'Date de mise à jour des infos récupérées : ' . $json['updated']);
log::add('trains', 'debug', 'infos récupérées : ' . json_encode($departs));
$result = (object) [];
$result->updated = $json['updated'];
$result->departs = $departs;
$trainsCmd = $trains->getCmd(null, 'Departs');
if (is_object($trainsCmd)) {
$trainsCmd->event(json_encode($result));
}
$trains->refreshWidget();
}
}
}
}
示例14: cron
public static function cron()
{
foreach (self::byType('networks') as $networks) {
$autorefresh = $networks->getConfiguration('autorefresh');
if ($networks->getIsEnable() == 1 && $autorefresh != '') {
try {
$c = new Cron\CronExpression($autorefresh, new Cron\FieldFactory());
if ($c->isDue()) {
try {
$networks->ping();
} catch (Exception $exc) {
log::add('networks', 'error', __('Erreur pour ', __FILE__) . $networks->getHumanName() . ' : ' . $exc->getMessage());
}
}
} catch (Exception $exc) {
log::add('networks', 'error', __('Expression cron non valide pour ', __FILE__) . $networks->getHumanName() . ' : ' . $autorefresh);
}
}
}
}
示例15: openzwave_update
function openzwave_update()
{
if (!file_exists(dirname(__FILE__) . '/../data')) {
mkdir(dirname(__FILE__) . '/../data');
if (file_exists('/opt/python-openzwave/xml_backups')) {
shell_exec('cp -R /opt/python-openzwave/xml_backups ' . dirname(__FILE__) . '/../data');
shell_exec('cp -R /opt/python-openzwave/zwcfg_*.xml ' . dirname(__FILE__) . '/../data');
shell_exec('rm -rf /opt/python-openzwave/xml_backups');
shell_exec('rm -rf /opt/python-openzwave/zwcfg_*.xml');
}
}
$cron = cron::byClassAndFunction('openzwave', 'pull');
if (is_object($cron)) {
$cron->remove();
}
if (count(eqLogic::byType('zwave')) > 0) {
log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576');
}
openzwave::syncconfOpenzwave();
}