本文整理汇总了PHP中KLogger::logError方法的典型用法代码示例。如果您正苦于以下问题:PHP KLogger::logError方法的具体用法?PHP KLogger::logError怎么用?PHP KLogger::logError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLogger
的用法示例。
在下文中一共展示了KLogger::logError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logQuery
/**
* Führt eine SQL Query aus und schreibt sie in die Logdatei.
* @param KLogger $log Logdatei Objekt
* @param rex_sql $sql SQL Objekt
* @param String $query SQL Query
*/
public static function logQuery(&$log, &$sql, $query)
{
$sql->setQuery($query);
if ($sql->getError() == '') {
$log->logInfo('>> [QRY] ' . htmlentities($query));
} else {
$log->logError('>> [QRY] ' . htmlentities($query));
$log->logError('>> [QRY] ' . $sql->getError());
}
}
示例2: importDataFromSource
//.........这里部分代码省略.........
$ps_format = isset($pa_options['format']) && $pa_options['format'] ? $pa_options['format'] : null;
if (!($o_reader = $t_mapping->getDataReader($ps_source, $ps_format))) {
ca_data_importers::logImportError(_t("Could not open source %1 (format=%2)", $ps_source, $ps_format), $va_log_import_error_opts);
if ($o_trans) {
$o_trans->rollback();
}
return false;
}
$va_reader_opts = array('basePath' => $t_mapping->getSetting('basePath'));
if (!$o_reader->read($ps_source, $va_reader_opts)) {
ca_data_importers::logImportError(_t("Could not read source %1 (format=%2)", $ps_source, $ps_format), $va_log_import_error_opts);
if ($o_trans) {
$o_trans->rollback();
}
return false;
}
$o_log->logDebug(_t('Finished reading input source at %1 seconds', $t->getTime(4)));
$vn_dataset_count = $vb_import_all_datasets ? (int) $o_reader->getDatasetCount() : 1;
for ($vn_dataset = 0; $vn_dataset < $vn_dataset_count; $vn_dataset++) {
if (!$o_reader->setCurrentDataset($vn_dataset)) {
continue;
}
$vn_num_items = $o_reader->numRows();
$o_log->logDebug(_t('Found %1 rows in input source', $vn_num_items));
$o_progress->setTotal($vn_num_items);
$o_progress->start(_t('Importing from %1', $ps_source), array('window' => $r_progress));
if ($po_request && isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback'])) {
$ps_callback($po_request, $pn_file_number, $pn_number_of_files, $ps_source, 0, $vn_num_items, _t('Importing from %1', $ps_source), time() - $vn_start_time, memory_get_usage(true), 0, ca_data_importers::$s_num_import_errors);
}
// What are we importing?
$vn_table_num = $t_mapping->get('table_num');
if (!($t_subject = $o_dm->getInstanceByTableNum($vn_table_num))) {
// invalid table
$o_log->logError(_t('Mapping uses invalid table %1 as target', $vn_table_num));
if ($o_trans) {
$o_trans->rollback();
}
return false;
}
$t_subject->setTransaction($o_trans);
$vs_subject_table_name = $t_subject->tableName();
$t_label = $t_subject->getLabelTableInstance();
$t_label->setTransaction($o_trans);
$vs_label_display_fld = $t_subject->getLabelDisplayField();
$vs_subject_table = $t_subject->tableName();
$vs_type_id_fld = $t_subject->getTypeFieldName();
$vs_idno_fld = $t_subject->getProperty('ID_NUMBERING_ID_FIELD');
// get mapping rules
$va_mapping_rules = $t_mapping->getRules();
// get mapping groups
$va_mapping_groups = $t_mapping->getGroups();
$va_mapping_items = $t_mapping->getItems();
//
// Mapping-level settings
//
$vs_type_mapping_setting = $t_mapping->getSetting('type');
$vn_num_initial_rows_to_skip = $t_mapping->getSetting('numInitialRowsToSkip');
if (!in_array($vs_import_error_policy = $t_mapping->getSetting('errorPolicy'), array('ignore', 'stop'))) {
$vs_import_error_policy = 'ignore';
}
if (!in_array($vs_existing_record_policy = $t_mapping->getSetting('existingRecordPolicy'), array('none', 'skip_on_idno', 'skip_on_preferred_labels', 'merge_on_idno', 'merge_on_preferred_labels', 'merge_on_idno_and_preferred_labels', 'merge_on_idno_with_replace', 'merge_on_preferred_labels_with_replace', 'merge_on_idno_and_preferred_labels_with_replace', 'overwrite_on_idno', 'overwrite_on_preferred_labels', 'overwrite_on_idno_and_preferred_labels'))) {
$vs_existing_record_policy = 'none';
}
// Analyze mapping for figure out where type, idno, preferred label and other mandatory fields are coming from
$vn_type_id_mapping_item_id = $vn_idno_mapping_item_id = null;
$va_preferred_label_mapping_ids = array();
示例3: exportRecord
/**
* Export a single record using the mapping defined by this exporter and return as string
* @param string $ps_exporter_code defines the exporter to use
* @param int $pn_record_id Primary key of the record to export. Record type is determined by the table_num field for this exporter.
* @param array $pa_options
* singleRecord = Gives a signal to the export format implementation that this is a single record export. For certain formats
* this might trigger different behavior, for instance the XML export format prepends the item-level output with <?xml ... ?>
* in those cases.
* rdfMode = Signals the implementation that this is an RDF mode export
* logDirectory = path to directory where logs should be written
* logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. Constants are, in descending order of shrillness:
* KLogger::EMERG = Emergency messages (system is unusable)
* KLogger::ALERT = Alert messages (action must be taken immediately)
* KLogger::CRIT = Critical conditions
* KLogger::ERR = Error conditions
* KLogger::WARN = Warnings
* KLogger::NOTICE = Notices (normal but significant conditions)
* KLogger::INFO = Informational messages
* KLogger::DEBUG = Debugging messages
* logger = Optional ready-to-use instance of KLogger to use for logging/debugging
* @return string Exported record as string
*/
public static function exportRecord($ps_exporter_code, $pn_record_id, $pa_options = array())
{
// The variable cache is valid for the whole record export.
// It's being modified in ca_data_exporters::processExporterItem
// and then reset here if we move on to the next record.
ca_data_exporters::$s_variables = array();
$o_log = caGetOption('logger', $pa_options);
// only set up new logging facilities if no existing one has been passed down
if (!$o_log || !$o_log instanceof KLogger) {
$vs_log_dir = caGetOption('logDirectory', $pa_options);
if (!file_exists($vs_log_dir) || !is_writable($vs_log_dir)) {
$vs_log_dir = caGetTempDirPath();
}
if (!($vn_log_level = caGetOption('logLevel', $pa_options))) {
$vn_log_level = KLogger::INFO;
}
$o_log = new KLogger($vs_log_dir, $vn_log_level);
}
// make sure we pass logger to item processor
$pa_options['logger'] = $o_log;
ca_data_exporters::$s_instance_cache = array();
$t_exporter = ca_data_exporters::loadExporterByCode($ps_exporter_code);
if (!$t_exporter) {
$o_log->logError(_t("Failed to load exporter with code '%1' for item with ID %2", $ps_exporter_code, $pn_record_id));
return false;
}
$o_log->logInfo(_t("Successfully loaded exporter with code '%1' for item with ID %2", $ps_exporter_code, $pn_record_id));
$va_export = array();
foreach ($t_exporter->getTopLevelItems() as $va_item) {
$va_export = array_merge($va_export, $t_exporter->processExporterItem($va_item['item_id'], $t_exporter->get('table_num'), $pn_record_id, $pa_options));
}
$o_log->logInfo(_t("The export tree for exporter code '%1' and item with ID %2 is now ready to be processed by the export format (i.e. transformed to XML, for example).", $ps_exporter_code, $pn_record_id));
$o_log->logDebug(print_r($va_export, true));
// we may wanna auto-load this?
switch ($t_exporter->getSetting('exporter_format')) {
case 'XML':
$o_export = new ExportXML();
break;
case 'MARC':
$o_export = new ExportMARC();
break;
case 'CSV':
$o_export = new ExportCSV();
break;
case 'ExifTool':
$o_export = new ExportExifTool();
break;
default:
return;
}
$o_export->setLogger($o_log);
// if someone wants to mangle the whole tree ... well, go right ahead
$o_manager = new ApplicationPluginManager();
$o_manager->hookExportRecord(array('exporter_instance' => $t_exporter, 'record_id' => $pn_record_id, 'export' => &$va_export));
$pa_options['settings'] = $t_exporter->getSettings();
$vs_wrap_before = $t_exporter->getSetting('wrap_before_record');
$vs_wrap_after = $t_exporter->getSetting('wrap_after_record');
if ($vs_wrap_before || $vs_wrap_after) {
$pa_options['singleRecord'] = false;
}
$vs_export = $o_export->processExport($va_export, $pa_options);
if (strlen($vs_wrap_before) > 0) {
$vs_export = $vs_wrap_before . "\n" . $vs_export;
}
if (strlen($vs_wrap_after) > 0) {
$vs_export = $vs_export . "\n" . $vs_wrap_after;
}
return $vs_export;
}
示例4: KLogger
*/
// Check Request for IPN
if ($_GET['q'] == 'ipn') {
require_once "Handler/PaypalHandler.php";
// PayPal has its own logger
$paypal_log = new KLogger($_SERVER['DOCUMENT_ROOT'] . '/' . $CONFIG['paths']['base_url'] . '/logs/paypal', Klogger::DEBUG);
$paypal_log->logInfo('Received IPN Request');
$handler = new PaypalHandler();
$status = $handler->process();
// success could have multiple payments to log
if ($status['status'] == true) {
foreach ($status['message'] as $payment) {
$paypal_log->logInfo('Registration #' . $payment->order_id . ' - ' . $payment->payment_amount . ' paid in full');
}
} else {
$paypal_log->logError($status['message']);
$paypal_log->logDebug(print_r(debug_backtrace(), true));
}
// no more IPN processing required
exit;
}
// Set some template defaults
global $smarty;
$smarty->assign('app_name', variable_get('app_name', 'Leaguerunner'));
$smarty->assign('app_admin_name', variable_get('app_admin_name', 'Leaguerunner Admin'));
$smarty->assign('app_admin_email', variable_get('app_admin_email', 'webmaster@localhost'));
$smarty->assign('app_version', '2.8.5');
$smarty->assign('base_url', $CONFIG['paths']['base_url']);
$smarty->assign('site_name', 'Your Ultimate Club');
$smarty->assign('site_slogan', 'Slogan about Your Ultimate Club');
//TODO NOTE: Testing Only, MUST BE REMOVED for Production
示例5: importMediaFromDirectory
/**
* @param RequestHTTP $po_request
* @param null|array $pa_options
* progressCallback =
* reportCallback =
* sendMail =
* log = log directory path
* logLevel = KLogger constant for minimum log level to record. Default is KLogger::INFO. Constants are, in descending order of shrillness:
* KLogger::EMERG = Emergency messages (system is unusable)
* KLogger::ALERT = Alert messages (action must be taken immediately)
* KLogger::CRIT = Critical conditions
* KLogger::ERR = Error conditions
* KLogger::WARN = Warnings
* KLogger::NOTICE = Notices (normal but significant conditions)
* KLogger::INFO = Informational messages
* KLogger::DEBUG = Debugging messages
* @return array
*/
public static function importMediaFromDirectory($po_request, $pa_options = null)
{
global $g_ui_locale_id;
$vs_log_dir = caGetOption('log', $pa_options, __CA_APP_DIR__ . "/log");
$vs_log_level = caGetOption('logLevel', $pa_options, "INFO");
if (!is_writeable($vs_log_dir)) {
$vs_log_dir = caGetTempDirPath();
}
$vn_log_level = BatchProcessor::_logLevelStringToNumber($vs_log_level);
$o_log = new KLogger($vs_log_dir, $vn_log_level);
$vs_import_target = caGetOption('importTarget', $pa_options, 'ca_objects');
$t_instance = $po_request->getAppDatamodel()->getInstance($vs_import_target);
$o_eventlog = new Eventlog();
$t_set = new ca_sets();
$va_notices = $va_errors = array();
$vb_we_set_transaction = false;
$o_trans = isset($pa_options['transaction']) && $pa_options['transaction'] ? $pa_options['transaction'] : null;
if (!$o_trans) {
$vb_we_set_transaction = true;
$o_trans = new Transaction($t_set->getDb());
}
$o_batch_log = new Batchlog(array('user_id' => $po_request->getUserID(), 'batch_type' => 'MI', 'table_num' => (int) $t_instance->tableNum(), 'notes' => '', 'transaction' => $o_trans));
if (!is_dir($pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => $vs_msg = _t("Specified import directory '%1' is invalid", $pa_options['importFromDirectory'])));
$o_log->logError($vs_msg);
return null;
}
$vs_batch_media_import_root_directory = $po_request->config->get('batch_media_import_root_directory');
if (!preg_match("!^{$vs_batch_media_import_root_directory}!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => $vs_msg = _t("Specified import directory '%1' is invalid", $pa_options['importFromDirectory'])));
$o_log->logError($vs_msg);
return null;
}
if (preg_match("!\\.\\./!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => $vs_msg = _t("Specified import directory '%1' is invalid", $pa_options['importFromDirectory'])));
$o_log->logError($vs_msg);
return null;
}
$vb_include_subdirectories = (bool) $pa_options['includeSubDirectories'];
$vb_delete_media_on_import = (bool) $pa_options['deleteMediaOnImport'];
$vs_import_mode = $pa_options['importMode'];
$vs_match_mode = $pa_options['matchMode'];
$vn_type_id = $pa_options[$vs_import_target . '_type_id'];
$vn_rep_type_id = $pa_options['ca_object_representations_type_id'];
$va_limit_matching_to_type_ids = $pa_options[$vs_import_target . '_limit_matching_to_type_ids'];
$vn_access = $pa_options[$vs_import_target . '_access'];
$vn_object_representation_access = $pa_options['ca_object_representations_access'];
$vn_status = $pa_options[$vs_import_target . '_status'];
$vn_object_representation_status = $pa_options['ca_object_representations_status'];
$vn_rel_type_id = isset($pa_options[$vs_import_target . '_representation_relationship_type']) ? $pa_options[$vs_import_target . '_representation_relationship_type'] : null;
$vn_mapping_id = $pa_options[$vs_import_target . '_mapping_id'];
$vn_object_representation_mapping_id = $pa_options['ca_object_representations_mapping_id'];
$vs_idno_mode = $pa_options['idnoMode'];
$vs_idno = $pa_options['idno'];
$vs_representation_idno_mode = $pa_options['representationIdnoMode'];
$vs_representation_idno = $pa_options['representation_idno'];
$vs_set_mode = $pa_options['setMode'];
$vs_set_create_name = $pa_options['setCreateName'];
$vn_set_id = $pa_options['set_id'];
$vn_locale_id = $pa_options['locale_id'];
$vs_skip_file_list = $pa_options['skipFileList'];
$vs_skip_file_list = $pa_options['skipFileList'];
$vb_allow_duplicate_media = $pa_options['allowDuplicateMedia'];
$va_relationship_type_id_for = array();
if (is_array($va_create_relationship_for = $pa_options['create_relationship_for'])) {
foreach ($va_create_relationship_for as $vs_rel_table) {
$va_relationship_type_id_for[$vs_rel_table] = $pa_options['relationship_type_id_for_' . $vs_rel_table];
}
}
if (!$vn_locale_id) {
$vn_locale_id = $g_ui_locale_id;
}
$va_files_to_process = caGetDirectoryContentsAsList($pa_options['importFromDirectory'], $vb_include_subdirectories);
$o_log->logInfo(_t('Found %1 files in directory \'%2\'', sizeof($va_files_to_process), $pa_options['importFromDirectory']));
if ($vs_set_mode == 'add') {
$t_set->load($vn_set_id);
} else {
if ($vs_set_mode == 'create' && $vs_set_create_name) {
$va_set_ids = $t_set->getSets(array('user_id' => $po_request->getUserID(), 'table' => $t_instance->tableName(), 'access' => __CA_SET_EDIT_ACCESS__, 'setIDsOnly' => true, 'name' => $vs_set_create_name));
$vn_set_id = null;
if (is_array($va_set_ids) && sizeof($va_set_ids) > 0) {
$vn_possible_set_id = array_shift($va_set_ids);
//.........这里部分代码省略.........
示例6: request_ip_in_white_list
function request_ip_in_white_list()
{
$klog = new KLogger(dirname(__FILE__), 'log/BeginShellTask', KLogger::DEBUG);
$mysqli = new mysqli(AREA_CONFIG::$dbHost, 'itil', 'itil', AREA_CONFIG::$dbName, AREA_CONFIG::$dbPort);
if ($mysqli->connect_errno) {
$klog->logError('line' . __LINE__ . ': mysqli connect errno = ' . $mysqli->connect_errno);
return false;
}
$sql = "SET NAMES 'utf8'";
$ret = $mysqli->query($sql);
if (true != $ret) {
$klog->logError('line' . __LINE__ . ': mysqli query err, sql = ' . $sql);
return false;
}
$sql = 'select ip from shell_white_ip';
$mysql_ret = $mysqli->query($sql);
if (true != $mysql_ret) {
$klog->logError('line' . __LINE__ . ': mysqli query err, sql = ' . $sql);
return false;
}
$ip_while_list = array();
$ip_info = $mysql_ret->fetch_assoc();
while ($ip_info) {
$ip_while_list[] = $ip_info['ip'];
$ip_info = $mysql_ret->fetch_assoc();
}
if (!in_array($_SERVER["REMOTE_ADDR"], $ip_while_list)) {
return false;
}
return true;
}
示例7: caLoadULAN
/**
*
*
* @return string
*/
function caLoadULAN($ps_path_to_ulan_data = null, $ps_path_to_ulan_config = null, $pa_options = null)
{
require_once __CA_LIB_DIR__ . '/core/Db.php';
require_once __CA_LIB_DIR__ . '/core/Configuration.php';
require_once __CA_LIB_DIR__ . '/ca/Utils/DataMigrationUtils.php';
require_once __CA_MODELS_DIR__ . '/ca_locales.php';
require_once __CA_MODELS_DIR__ . '/ca_entities.php';
require_once __CA_MODELS_DIR__ . '/ca_entities_x_entities.php';
require_once __CA_MODELS_DIR__ . '/ca_lists.php';
require_once __CA_MODELS_DIR__ . '/ca_list_items.php';
require_once __CA_MODELS_DIR__ . '/ca_list_items_x_list_items.php';
require_once __CA_MODELS_DIR__ . '/ca_relationship_types.php';
$t = new Timer();
$o_log = new KLogger(__CA_APP_DIR__ . '/log', KLogger::INFO);
$va_parent_child_links = array();
$va_item_item_links = array();
$va_ulan_id_to_item_id = array();
$o_log->logInfo("Starting import of Getty ULAN");
define('__CA_DONT_DO_SEARCH_INDEXING__', true);
$_ = new Zend_Translate('gettext', __CA_APP_DIR__ . '/locale/en_US/messages.mo', 'en_US');
$t_locale = new ca_locales();
$pn_en_locale_id = $t_locale->loadLocaleByCode('en_US');
if (!($o_config = Configuration::load($ps_path_to_ulan_config))) {
$o_log->logError("Could not load ULAN import configuration file");
die("ERROR: Could not load ULAN import configuration\n");
}
$vs_ulan_import_mode = $o_config->get('ulan_import_target');
$t_list = null;
if ($vs_ulan_import_mode == 'ca_entities') {
$va_ulan_types = $o_config->getAssoc('ulan_entity_types');
$va_mapping = $o_config->getAssoc('ulan_entity_mapping');
} elseif ($vs_ulan_import_mode == 'ca_list_items') {
$va_ulan_types = $o_config->getAssoc('ulan_list_item_types');
if (!($vs_ulan_list_code = $o_config->get('ulan_import_list'))) {
$vs_ulan_list_code = 'ULAN';
}
// create vocabulary list record (if it doesn't exist already)
$t_list = new ca_lists();
if (!$t_list->load(array('list_code' => $vs_ulan_list_code))) {
$t_list->setMode(ACCESS_WRITE);
$t_list->set('list_code', $vs_ulan_list_code);
$t_list->set('is_system_list', 0);
$t_list->set('is_hierarchical', 1);
$t_list->set('use_as_vocabulary', 1);
$t_list->insert();
if ($t_list->numErrors()) {
$o_log->logError("Could not create list record for ULAN: " . join('; ', $t_list->getErrors()));
die("ERROR: couldn't create ca_list row for ULAN: " . join('; ', $t_list->getErrors()) . "\n");
}
$t_list->addLabel(array('name' => 'Union List of Artist Names'), $pn_en_locale_id, null, true);
}
$vn_list_id = $t_list->getPrimaryKey();
$va_mapping = $o_config->getAssoc('ulan_list_item_mapping');
} else {
$o_log->logError("Invalid ULAN import mode {$vs_ulan_import_mode}");
die("ERROR: invalid ULAN import mode {$vs_ulan_import_mode}\n");
}
$vn_last_message_length = 0;
$vn_term_count = 0;
$va_subject = array();
foreach (array('ULAN1.xml', 'ULAN2.xml', 'ULAN3.xml') as $vs_file) {
if (!$ps_path_to_ulan_data) {
$ps_path_to_ulan_data = ".";
}
if (!file_exists($ps_path_to_ulan_data . "/{$vs_file}")) {
$o_log->logError("Could not find ULAN data file {$vs_file}");
print "[ERROR] cannot find ULAN data.\n";
continue;
}
$o_log->logInfo("Processing ULAN file {$vs_file}");
print "[Notice] Processing ULAN file {$vs_file}\n";
// load
$o_xml = new XMLReader();
$o_xml->open($ps_path_to_ulan_data . '/' . $vs_file);
while ($o_xml->read()) {
switch ($o_xml->name) {
# ---------------------------
case 'Subject':
if ($o_xml->nodeType == XMLReader::END_ELEMENT) {
if (in_array($va_subject['subject_id'], array('500000000', '500000001'))) {
break;
}
// skip top-level root
$vs_preferred_term = $va_subject['preferred_term'];
$pb_is_enabled = false;
switch ($va_subject['record_type']) {
case 'Person':
default:
$vn_type_id = $va_ulan_types['Person'];
$pb_is_enabled = true;
break;
case 'Corporate Body':
$vn_type_id = $va_ulan_types['Corporate Body'];
$pb_is_enabled = true;
break;
//.........这里部分代码省略.........
示例8: logError
/**
* logError
*
* @todo this should be moved to Error class
* and shouldn't be called direcly
*
* @param string $string The full error string
*
* @return void
*/
function logError($string)
{
require_once THIRDPARTY . 'KLogger.php';
$log = new KLogger(ROOT . 'logs/', KLogger::ERR);
$log->logError($string);
}