本文整理汇总了PHP中KLogger::logDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP KLogger::logDebug方法的具体用法?PHP KLogger::logDebug怎么用?PHP KLogger::logDebug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLogger
的用法示例。
在下文中一共展示了KLogger::logDebug方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logAndDie
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
header("Content-Type: text/plain");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
function logAndDie($log, $message, $code)
{
http_response_code($code);
$log->logFatal($message);
die($message);
}
require_once 'KLogger.php';
$log = new KLogger('.', KLogger::INFO);
$log->logDebug('Opened connection from ' . $_SERVER['REMOTE_ADDR']);
$password = '';
$remoteaddr = '';
if ($_REQUEST['password'] != $password || $_SERVER['REMOTE_ADDR'] != $remoteaddr) {
logAndDie($log, 'Bad Authentication: ' . $_SERVER['REMOTE_ADDR'], 403);
}
$log->logDebug('Authenticated.');
require_once 'mysql_settings.php';
$mysqli = new mysqli(mysqlSettings::HOSTNAME, mysqlSettings::USERNAME, mysqlSettings::PASSWORD, mysqlSettings::DATABASE);
if ($mysqli->connect_error) {
logAndDie($log, 'MySQL Connection Error', 500);
}
$log->logDebug('Connected to MySQL - Request mode: ' . $_REQUEST['mode']);
if ($_REQUEST['mode'] === 'update') {
$query = sprintf("UPDATE `logs_users` SET `ip` = '%s' WHERE `name` = '%s'", $mysqli->real_escape_string($_REQUEST['ip']), strtolower($mysqli->real_escape_string($_REQUEST['name'])));
$mysqli->query($query) or logAndDie($log, 'MySQL Query Error: ' . $query, 500);
示例2: 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;
}
示例3: importDataFromSource
//.........这里部分代码省略.........
$t = new Timer();
$vn_start_time = time();
$va_log_import_error_opts = array('startTime' => $vn_start_time, 'window' => $r_errors, 'log' => $o_log, 'request' => $po_request, 'progressCallback' => isset($pa_options['progressCallback']) && ($ps_callback = $pa_options['progressCallback']) ? $ps_callback : null, 'reportCallback' => isset($pa_options['reportCallback']) && ($ps_callback = $pa_options['reportCallback']) ? $ps_callback : null);
global $g_ui_locale_id;
// constant locale set by index.php for web requests
$vn_locale_id = isset($pa_options['locale_id']) && (int) $pa_options['locale_id'] ? (int) $pa_options['locale_id'] : $g_ui_locale_id;
$o_dm = $t_mapping->getAppDatamodel();
$o_progress->start(_t('Reading %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, 100, _t('Reading %1', $ps_source), time() - $vn_start_time, memory_get_usage(true), 0, ca_data_importers::$s_num_import_errors);
}
// Open file
$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 ($vb_use_ncurses) {
ncurses_end();
}
if ($o_trans) {
$o_trans->rollback();
}
return false;
}
if (!$o_reader->read($ps_source, array('basePath' => $t_mapping->getSetting('basePath')))) {
ca_data_importers::logImportError(_t("Could not read source %1 (format=%2)", $ps_source, $ps_format), $va_log_import_error_opts);
if ($vb_use_ncurses) {
ncurses_end();
}
if ($o_trans) {
$o_trans->rollback();
}
return false;
}
$o_log->logDebug(_t('Finished reading input source at %1 seconds', $t->getTime(4)));
$vn_num_items = $o_reader->numRows();
$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
if ($vb_use_ncurses) {
ncurses_end();
}
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();
//
示例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
//$smarty->force_compile = true;
示例5: switch
// Include our configuration (holding defines for the requires)
require_once BASEPATH . 'include/config/global.inc.php';
// We include all needed files here, even though our templates could load them themself
require_once INCLUDE_DIR . '/autoloader.inc.php';
// Command line switches
array_shift($argv);
foreach ($argv as $option) {
switch ($option) {
case '-f':
$monitoring->setStatus($cron_name . "_disabled", "yesno", 0);
break;
}
}
// Load 3rd party logging library for running crons
$log = new KLogger('logs/' . $cron_name . '.txt', KLogger::INFO);
$log->LogDebug('Starting ' . $cron_name);
// Load the start time for later runtime calculations for monitoring
$cron_start[$cron_name] = microtime(true);
// Check if our cron is activated
if ($monitoring->isDisabled($cron_name)) {
$log->logFatal('Cronjob is currently disabled due to errors, use -f option to force running cron.');
$monitoring->endCronjob($cron_name, 'E0018', 1, true, false);
}
// Mark cron as running for monitoring
$log->logDebug('Marking cronjob as running for monitoring');
$monitoring->setStatus($cron_name . '_starttime', 'date', time());
// Check if we need to halt our crons due to an outstanding upgrade
if ($setting->getValue('DB_VERSION') != DB_VERSION || $config['version'] != CONFIG_VERSION) {
$log->logFatal('Cronjob is currently disabled due to required upgrades. Import any outstanding SQL files and check your configuration file.');
$monitoring->endCronjob($cron_name, 'E0075', 0, true, false);
}
示例6: importMediaFromDirectory
//.........这里部分代码省略.........
$va_skip_list = preg_split("![\r\n]+!", $vs_skip_file_list);
foreach ($va_skip_list as $vn_i => $vs_skip) {
if (!strlen($va_skip_list[$vn_i] = trim($vs_skip))) {
unset($va_skip_list[$vn_i]);
}
}
$vn_c = 0;
$vn_start_time = time();
$va_report = array();
foreach ($va_files_to_process as $vs_file) {
$va_tmp = explode("/", $vs_file);
$f = array_pop($va_tmp);
$d = array_pop($va_tmp);
array_push($va_tmp, $d);
$vs_directory = join("/", $va_tmp);
// Skip file names using $vs_skip_file_list
if (BatchProcessor::_skipFile($f, $va_skip_list)) {
$o_log->logInfo(_t('Skipped file %1 because it was on the skipped files list', $f));
continue;
}
$vs_relative_directory = preg_replace("!{$vs_batch_media_import_root_directory}[/]*!", "", $vs_directory);
// does representation already exist?
if (!$vb_allow_duplicate_media && ($t_dupe = ca_object_representations::mediaExists($vs_file))) {
$va_notices[$vs_relative_directory . '/' . $f] = array('idno' => '', 'label' => $f, 'message' => $vs_msg = _t('Skipped %1 from %2 because it already exists %3', $f, $vs_relative_directory, caEditorLink($po_request, _t('(view)'), 'button', 'ca_object_representations', $t_dupe->getPrimaryKey())), 'status' => 'SKIPPED');
$o_log->logInfo($vs_msg);
continue;
}
$t_instance = $po_request->getAppDatamodel()->getInstance($vs_import_target, false);
$t_instance->setTransaction($o_trans);
$vs_modified_filename = $f;
$va_extracted_idnos_from_filename = array();
if (in_array($vs_import_mode, array('TRY_TO_MATCH', 'ALWAYS_MATCH')) || is_array($va_create_relationship_for) && sizeof($va_create_relationship_for)) {
foreach ($va_regex_list as $vs_regex_name => $va_regex_info) {
$o_log->logDebug(_t("Processing mediaFilenameToObjectIdnoRegexes entry %1", $vs_regex_name));
foreach ($va_regex_info['regexes'] as $vs_regex) {
switch ($vs_match_mode) {
case 'DIRECTORY_NAME':
$va_names_to_match = array($d);
$o_log->logDebug(_t("Trying to match on directory '%1'", $d));
break;
case 'FILE_AND_DIRECTORY_NAMES':
$va_names_to_match = array($f, $d);
$o_log->logDebug(_t("Trying to match on directory '%1' and file name '%2'", $d, $f));
break;
default:
case 'FILE_NAME':
$va_names_to_match = array($f);
$o_log->logDebug(_t("Trying to match on file name '%1'", $f));
break;
}
// are there any replacements? if so, try to match each element in $va_names_to_match AND all results of the replacements
if (is_array($va_replacements_list) && sizeof($va_replacements_list) > 0) {
$va_names_to_match_copy = $va_names_to_match;
foreach ($va_names_to_match_copy as $vs_name) {
foreach ($va_replacements_list as $vs_replacement_code => $va_replacement) {
if (isset($va_replacement['search']) && is_array($va_replacement['search'])) {
$va_replace = caGetOption('replace', $va_replacement);
$va_search = array();
foreach ($va_replacement['search'] as $vs_search) {
$va_search[] = '!' . $vs_search . '!';
}
$vs_replacement_result = @preg_replace($va_search, $va_replace, $vs_name);
if (is_null($vs_replacement_result)) {
$o_log->logError(_t("There was an error in preg_replace while processing replacement %1.", $vs_replacement_code));
}
if ($vs_replacement_result && strlen($vs_replacement_result) > 0) {