本文整理汇总了PHP中kohana::log方法的典型用法代码示例。如果您正苦于以下问题:PHP kohana::log方法的具体用法?PHP kohana::log怎么用?PHP kohana::log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kohana
的用法示例。
在下文中一共展示了kohana::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAudioInfo
public static function getAudioInfo($path)
{
if (!is_file($path)) {
kohana::log('debug', 'Asked for audio info on non-existant file: "' . $path . '"');
return FALSE;
}
$id3 = new getID3();
$info = $id3->analyze($path);
if (!empty($info['error'])) {
kohana::log('debug', 'Unable to analyze "' . $path . '" because ' . implode(' - ', $info['error']));
return FALSE;
}
switch ($info['audio']['dataformat']) {
case 'wav':
return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['streams'][0]['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => $info['audio']['bits_per_sample'], 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
case 'mp1':
return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['streams'][0]['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => $info['audio']['bits_per_sample'], 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
case 'mp3':
return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => NULL, 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
case 'ogg':
return array('type' => $info['audio']['dataformat'], 'compression' => number_format($info['audio']['compression_ratio'], 4), 'channels' => $info['audio']['channels'], 'rates' => $info['audio']['sample_rate'], 'byterate' => $info['audio']['bitrate'], 'bits' => NULL, 'size' => $info['filesize'], 'length' => number_format($info['playtime_seconds'], 4));
default:
kohana::log('error', 'Unhandled media type(' . $info['audio']['dataformat'] . ') for file ' . $path);
}
return FALSE;
}
示例2: register
public static function register($driver, $hook)
{
$driverName = Telephony::getDriverName();
if (!$driverName or $driverName == 'none') {
return true;
} elseif (!class_exists($driverName)) {
Kohana::log('error', 'Telephony -> Unable to register the dialplan driver \'' . $driverName . '\'');
return false;
}
$hookClass = $driverName . '_' . $driver . '_Driver';
if (!class_exists($hookClass)) {
Kohana::log('error', 'Telephony -> Unable to register the dialplan hook \'' . $driver . '\'(' . $hookClass . ')');
return false;
}
if (empty(self::$dialplanSections)) {
kohana::log('debug', 'Telephony -> EVAL ' . $driverName . '::getDialplanSections();');
$sections = eval('return ' . $driverName . '::getDialplanSections();');
if (is_array($sections)) {
self::$dialplanSections = $sections;
}
}
if (!in_array($hook, self::$dialplanSections)) {
//Logger::ExceptionByCaller();
throw new Exception('The hook ' . $hook . ' is not a recognized telephony global hook. (While trying to register callback ' . $driver . ')');
}
// Register event as _telephony.action with the callback array as the callback
Event::add('_telephony.' . $hook, array($hookClass, $hook));
Kohana::log('debug', 'Telephony -> Added hook for _telephony.' . $hook . ' to call ' . $hookClass . '::' . $hook);
return TRUE;
}
示例3: echo_test
public static function echo_test()
{
$featureCode = new FeatureCode();
$featureCode['name'] = 'Echo Test';
$featureCode['registry'] = array('feature' => 'echo');
$featureCode->save();
try {
$location = Doctrine::getTable('Location')->findAll();
if (!$location->count()) {
throw Exception('Could not find location id');
}
$location_id = arr::get($location, 0, 'location_id');
$number = new Number();
$number['user_id'] = users::getAttr('user_id');
$number['number'] = '9999';
$number['location_id'] = $location_id;
$number['registry'] = array('ignoreFWD' => '0', 'ringtype' => 'ringing', 'timeout' => 20);
$dialplan = array('terminate' => array('transfer' => 0, 'voicemail' => 0, 'action' => 'hangup'));
$number['dialplan'] = $dialplan;
$number['class_type'] = 'FeatureCodeNumber';
$number['foreign_id'] = $featureCode['feature_code_id'];
$context = Doctrine::getTable('Context')->findOneByName('Outbound Routes');
$number['NumberContext']->fromArray(array(0 => array('context_id' => $context['context_id'])));
$numberType = Doctrine::getTable('NumberType')->findOneByClass('FeatureCodeNumber');
if (empty($numberType['number_type_id'])) {
return FALSE;
}
$number['NumberPool']->fromArray(array(0 => array('number_type_id' => $numberType['number_type_id'])));
$number->save();
return $number['number_id'];
} catch (Exception $e) {
kohana::log('error', 'Unable to initialize device number: ' . $e->getMessage());
throw $e;
}
}
示例4: runEvents
private static function runEvents($eventName, &$data = NULL)
{
kohana::log('debug', 'Running event ' . $eventName);
// Returns of the callbacks for event specified
$events = Event::get($eventName);
// Loop through each event, instantiate the event object, and call the event.
// NOTE: We do this because we rely on __get/__set methods in bluebox plugins and they must be able to use $object->
// to reference the current controller
$return_value = TRUE;
foreach ($events as $event) {
// Share our current controller w/ the event system
Event::$data =& $data;
// Go get our plugin object
$obj =& self::initialize($event[0]);
if (method_exists($obj, $event[1])) {
$return = call_user_func(array($obj, $event[1]));
kohana::log('debug', 'Plugin hook ' . get_class($obj) . '::' . $event[1] . '() returned ' . ($return ? 'true' : 'false'));
// If the func doesnt have a return or its not bool, assume true
if (is_null($return) || !is_bool($return)) {
$return = TRUE;
}
// Bitwise AND of all the returns (if any returns false, the event will return false)
$return_value = $return_value & $return;
} else {
throw new Exception('Tried to call plugin method ' . get_class($obj) . '::' . $event[1] . '(), but no such method exists. (Event ' . $eventName . ')');
}
// Do this to prevent data from getting 'stuck'
$clearData = '';
Event::$data =& $clearData;
}
return $return_value;
}
示例5: auto_verify_scheduled_task
/**
* Hook into the task scheduler. When run, the system checks the cache_occurrences table for records where the data cleaner has marked
* the record as data_cleaner_info "pass", record_status="C", the system then sets the record to verified automatically.
* @param string $last_run_date Date last run, or null if never run
* @param object $db Database object.
*/
function auto_verify_scheduled_task($last_run_date, $db)
{
$autoVerifyNullIdDiff = kohana::config('auto_verify.auto_accept_occurrences_with_null_id_difficulty');
global $processOldData;
$processOldData = kohana::config('auto_verify.process_old_data');
if (empty($autoVerifyNullIdDiff)) {
print_r("Unable to automatically verify occurrences when the auto_accept_occurrences_with_null_id_difficulty entry is empty.<br>");
kohana::log('error', 'Unable to automatically verify occurrences when the auto_accept_occurrences_with_null_id_difficulty configuration entry is empty.');
return false;
}
//Do we need to consider old data (probably as a one-off run) or just newly changed data.
$subQuery = "\n SELECT co.id";
if (!empty($processOldData) && $processOldData === 'true') {
$subQuery .= " \n FROM cache_occurrences co";
} else {
$subQuery .= " \n FROM occdelta od\n JOIN cache_occurrences co on co.id=od.id";
}
$subQuery .= "\n JOIN surveys s on s.id = co.survey_id AND s.auto_accept=true AND s.deleted=false\n LEFT JOIN cache_taxon_searchterms cts on cts.taxon_meaning_id = co.taxon_meaning_id \n WHERE co.data_cleaner_info='pass' AND co.record_status='C' AND co.record_substatus IS NULL\n AND ((" . $autoVerifyNullIdDiff . "=false AND cts.identification_difficulty IS NOT NULL AND cts.identification_difficulty<=s.auto_accept_max_difficulty) \n OR (" . $autoVerifyNullIdDiff . "=true AND (cts.identification_difficulty IS NULL OR cts.identification_difficulty<=s.auto_accept_max_difficulty)))";
$verificationTime = gmdate("Y\\/m\\/d H:i:s");
//Need to update cache_occurrences, as this table has already been built at this point.
$query = "\n INSERT INTO occurrence_comments (comment, generated_by, occurrence_id,record_status,record_substatus,created_by_id,updated_by_id,created_on,updated_on,auto_generated)\n SELECT 'Accepted based on automatic checks', 'system', id,'V','2',1,1,'" . $verificationTime . "','" . $verificationTime . "',true\n FROM occurrences\n WHERE id in\n (" . $subQuery . ");\n \n UPDATE occurrences\n SET \n record_status='V',\n record_substatus='2',\n release_status='R',\n verified_by_id=1,\n verified_on='" . $verificationTime . "',\n record_decision_source='M'\n WHERE id in\n (" . $subQuery . ");\n \n UPDATE cache_occurrences\n SET \n record_status='V',\n record_substatus='2',\n release_status='R',\n verified_on='" . $verificationTime . "',\n verifier='admin, core'\n WHERE id in\n (" . $subQuery . ");";
$results = $db->query($query)->result_array(false);
//Query to return count of records, as I was unable to pursuade the above query to output the number of updated
//records correctly.
$query = "\n SELECT count(id)\n FROM cache_occurrences co\n WHERE co.verified_on='" . $verificationTime . "';";
$results = $db->query($query)->result_array(false);
if (!empty($results[0]['count']) && $results[0]['count'] > 1) {
echo $results[0]['count'] . ' occurrence records have been automatically verified.</br>';
} elseif (!empty($results[0]['count']) && $results[0]['count'] === "1") {
echo '1 occurrence record has been automatically verified.</br>';
} else {
echo 'No occurrence records have been auto-verified.</br>';
}
}
示例6: log_error
/**
* Standardise the dumping of an exception message into the kohana log. E.g.
* try {
* ... code that throws exception ...
* } catch (Exception $e) {
* error::log_error('Error occurred whilst running some code', $e);
* }
*
* @param string $msg A description of where the error occurred.
* $param object $e The exception object.
*/
public static function log_error($msg, $e)
{
kohana::log('error', '#' . $e->getCode() . ': ' . $msg . '. ' . $e->getMessage() . ' at line ' . $e->getLine() . ' in file ' . $e->getFile());
// Double check the log threshold to avoid unnecessary work.
if (kohana::config('config.log_threshold') == 4) {
$trace = $e->getTrace();
$output = "Stack trace:\n";
for ($i = 0; $i < count($trace); $i++) {
if (array_key_exists('file', $trace[$i])) {
$file = $trace[$i]['file'];
} else {
$file = 'Unknown file';
}
if (array_key_exists('line', $trace[$i])) {
$line = $trace[$i]['line'];
} else {
$line = 'Unknown';
}
if (array_key_exists('function', $trace[$i])) {
$function = $trace[$i]['function'];
} else {
$function = 'Unknown function';
}
$output .= "\t" . $file . ' - line ' . $line . ' - ' . $function . "\n";
}
kohana::log('debug', $output);
}
}
示例7: createExtension
public static function createExtension()
{
Event::$data += array('voicemail_password' => self::generatePin(), 'voicemail_timezone' => kohana::config('locale.timezone'), 'voicemail_email_all_messages' => empty(Event::$data['user']['email_address']) ? 0 : 1, 'voicemail_delete_file' => 0, 'voicemail_attach_audio_file' => 1, 'voicemail_email_address' => empty(Event::$data['user']['email_address']) ? '' : Event::$data['user']['email_address']);
extract(Event::$data);
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', TRUE);
$name_append = '';
if (!empty($owner_name)) {
$name_append = ' for ' . $owner_name;
}
try {
$voicemail = new Voicemail();
$voicemail['name'] = 'VM ' . $extension . $name_append;
$voicemail['mailbox'] = $extension;
$voicemail['password'] = $voicemail_password;
$voicemail['account_id'] = $account_id;
$voicemail['plugins'] = array('timezone' => array('timezone' => $voicemail_timezone));
$voicemail['registry'] = array('email_all_messages' => $voicemail_email_all_messages, 'delete_file' => $voicemail_delete_file, 'attach_audio_file' => $voicemail_attach_audio_file, 'email_address' => $voicemail_email_address);
$voicemail->save();
$plugin = array('voicemail' => array('mwi_box' => $voicemail['voicemail_id']));
$device['plugins'] = arr::merge($device['plugins'], $plugin);
} catch (Exception $e) {
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
kohana::log('error', 'Unable to generate voicemail for device: ' . $e->getMessage());
throw $e;
}
Doctrine::getTable('Voicemail')->getRecordListener()->get('MultiTenant')->setOption('disabled', FALSE);
}
示例8: pre_save
protected function pre_save(&$object)
{
$errors = array();
libxml_use_internal_errors(TRUE);
$cleaned = array();
foreach ($object['registry'] as $section => $xml) {
$dom = new DOMDocument('1.0');
$dom->formatOutput = FALSE;
if (strlen(trim($xml)) == 0) {
kohana::log('debug', 'Section: ' . $section . ' Empty XML');
unset($cleaned[$section]);
continue;
}
try {
if ($dom->loadXML('<root>' . trim($xml) . '</root>')) {
$cleaned[$section] = trim(str_replace('<?xml version="1.0"?>', '', $dom->saveXML()));
kohana::log('debug', 'Section: ' . $section . ' Cleaned XML: ' . $dom->saveXML());
continue;
} else {
$errors[] = ucfirst($section);
}
} catch (Exception $e) {
$errors[] = ucfirst($section);
}
}
if (count($errors) > 0) {
throw new Exception('Please correct the XML errors in these sections: ' . implode(', ', $errors));
}
$object['registry'] = $cleaned;
kohana::log('debug', 'Successfully validated XML');
parent::pre_save($object);
}
示例9: package
public static function package($path)
{
Package_Message::log('debug', 'Attempting to import package ' . $path);
$filename = basename($path);
if (self::is_url($path)) {
$path = Package_Import_Remote::fetch($path);
}
$importPath = MODPATH . pathinfo($path, PATHINFO_FILENAME);
if (!class_exists('ZipArchive')) {
$return = FALSE;
Package_Message::log('debug', 'Attempting to unzip with: /usr/bin/unzip ' . $path . ' -d ' . MODPATH);
@system('/usr/bin/unzip ' . $path . ' -d ' . $importPath, $return);
if ($return !== 0) {
throw new Package_Import_Exception('System does not have zip archive support or could not extract ' . $path);
}
} else {
Package_Message::log('debug', 'Attempting to unzip with: ZipArchive->open(' . $path . ', ZIPARCHIVE::CHECKCONS)');
$zip = new ZipArchive();
if (!($error = $zip->open($path, ZIPARCHIVE::CHECKCONS))) {
switch ($error) {
case ZIPARCHIVE::ER_EXISTS:
throw new Package_Import_Exception('Package archive already exists: ' . $error);
case ZIPARCHIVE::ER_INCONS:
throw new Package_Import_Exception('Consistency check on the package archive failed: ' . $error);
case ZIPARCHIVE::ER_INVAL:
throw new Package_Import_Exception('Invalid argument while opening package archive: ' . $error);
case ZIPARCHIVE::ER_MEMORY:
throw new Package_Import_Exception('Memory allocation failure while opening package archive: ' . $error);
case ZIPARCHIVE::ER_NOENT:
throw new Package_Import_Exception('Could not locate package archive: ' . $error);
case ZIPARCHIVE::ER_NOZIP:
throw new Package_Import_Exception('Package archive is not a zip: ' . $error);
case ZIPARCHIVE::ER_OPEN:
throw new Package_Import_Exception('Cant open package archive: ' . $error);
case ZIPARCHIVE::ER_READ:
throw new Package_Import_Exception('Package archive read error: ' . $error);
case ZIPARCHIVE::ER_SEEK:
throw new Package_Import_Exception('Package archive seek error: ' . $error);
default:
throw new Package_Import_Exception('Unknown error while opening package archive: ' . $error);
}
}
if (is_dir($importPath)) {
throw new Package_Import_Exception('Import path `' . $importPath . '` already exists');
}
if (!@$zip->extractTo($importPath)) {
throw new Package_Import_Exception('Failed to extract package archive ' . $filename . ' or no permissions to unzip to ' . MODPATH);
}
$zip->close();
}
kohana::log('debug', 'Dynamically adding `' . $importPath . '` to kohana');
$loadedModules = Kohana::config('core.modules');
$modules = array_unique(array_merge($loadedModules, array($importPath)));
Kohana::config_set('core.modules', $modules);
Package_Catalog::disableRemote();
Package_Catalog::buildCatalog();
Package_Catalog::enableRemote();
return $importPath;
}
示例10: postSubmit
/**
* After submission, if we stored a pointer to a to_occurrence_id that does not yet exist,
* then store it in a static array with the occurrence_association_id so we can fill it in at
* the end of the submission.
*/
public function postSubmit($isInsert)
{
if ($this->to_occurrence_id_pointer) {
self::$to_occurrence_id_pointers[$this->id] = $this->to_occurrence_id_pointer;
$this->to_occurrence_id_pointer = FALSE;
kohana::log('debug', 'Pointers: ' . var_export(self::$to_occurrence_id_pointers, TRUE));
}
return true;
}
示例11: loadFormData
protected function loadFormData()
{
parent::loadFormData();
$this->pluginData['contexts'] = array();
if (!empty($_POST['simpleroute']['contexts'])) {
$this->pluginData['contexts'] = $_POST['simpleroute']['contexts'];
}
kohana::log('debug', print_r($this->pluginData, true));
return TRUE;
}
示例12: generateConfig
public static function generateConfig(&$base, &$xml = NULL)
{
if (empty($base['plugins']['media']['type'])) {
kohana::log('error', 'Attempted to configure media without a type');
return;
}
$type = $base['plugins']['media']['type'];
$data = array($base['plugins']['media'], $xml, $base);
kohana::log('debug', 'Attempting to configure media type ' . $type);
Event::run('bluebox.media.' . $type, $data);
}
示例13: generateConfiguration
public static function generateConfiguration()
{
list($media, $xml, $base) = Event::$data;
$media += array('tts_text' => 'Thank you for calling, your call is important to us.', 'tts_voice' => 'Flite/kal');
@(list($engine, $speaker) = explode('/', $media['tts_voice']));
$tts_string = 'say:' . preg_replace('/[^A-Za-z0-9.,!? ]/', '', $media['tts_text']);
kohana::log('debug', 'Configuring an auto-attendant to use ' . $engine . ' ' . $speaker . ' to ' . $tts_string);
$xml->setAttributeValue('', 'tts-engine', strtolower($engine));
$xml->setAttributeValue('', 'tts-voice', strtolower($speaker));
$xml->setAttributeValue('', 'greet-long', $tts_string);
$xml->setAttributeValue('', 'greet-short', $tts_string);
}
示例14: render
/**
* Renders all subviews passed in. Handles nested views within arrays. Uses recursion / No depth restriction.
*
* @param array $subviews An array of subviews. Can contain nested arrays with additional views.
* @return string All HTML from the subviews returned as a big string of HTML.
*/
public function render($subviews, $section = NULL)
{
$html = '';
if (!is_array($subviews)) {
$subviews = array($subviews);
}
if (!is_null($section) and !is_array($section)) {
$section = array($section);
}
if (is_array($section)) {
$section = array_map('strtolower', $section);
}
foreach ($subviews as $subview) {
// Handle nested views
if (is_array($subview)) {
self::render($subview, $section);
} else {
if (!$subview instanceof View) {
kohana::log('error', 'Can not render a subview that is not an instance of View');
continue;
}
if (isset($subview->render_conditional)) {
$renderConditions = $subview->render_conditional;
if (!is_array($renderConditions)) {
$renderConditions = array($renderConditions => FALSE);
}
if (Request::is_ajax()) {
if (isset($renderConditions['ajax']) and $renderConditions['ajax'] === FALSE) {
kohana::log('debug', 'Not rendering view due to ajax request');
continue;
}
}
if (isset($_REQUEST['qtipAjaxForm']) and $renderConditions['qtipAjaxForm'] === FALSE) {
kohana::log('debug', 'Not rendering view due to qtipAjaxForm request');
continue;
}
}
if (is_null($section)) {
$html .= $subview->render();
continue;
}
if (!isset($subview->section)) {
continue;
}
$subviewSection = strtolower($subview->section);
if (in_array($subviewSection, $section)) {
$html .= $subview->render();
}
}
}
return $html;
}
示例15: testRequestReportGetJson
public function testRequestReportGetJson()
{
$params = array('report' => 'library/websites/species_and_occurrence_counts.xml', 'reportSource' => 'local', 'mode' => 'json', 'auth_token' => $this->auth['read']['auth_token'], 'nonce' => $this->auth['read']['nonce']);
$url = report_helper::$base_url . 'index.php/services/report/requestReport?' . http_build_query($params, '', '&');
$session = curl_init();
curl_setopt($session, CURLOPT_URL, $url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// valid json response will decode
$response = json_decode(curl_exec($session), true);
kohana::log('debug', 'response: ' . print_r($response, true));
$this->assertEquals(true, isset($response[0]['title']), 'Report get JSON response not as expected');
}