public function testErrorAppendsStackTraceIfGivenAnError() { $message = 'an error occured'; $exception = new Exception('some error'); $this->logger->error($message, $exception); $this->assertLogContainsStackTrace($exception); $this->assertLogContainsErrorMessage($exception, $message); }
/** @return Tracker */ private function importTrackerStructure() { try { return $this->xml_import->createFromXMLFile($this->project->getID(), $this->template_path); } catch (Exception $exception) { $logger = new BackendLogger(); $logger->error('Unable to create first kanban for ' . $this->project->getId() . ': ' . $exception->getMessage()); return; } }
private function createDatabase($mediawiki_path) { $schema = strtr('plugin_mediawiki_' . $this->project_id, '-', '_'); $table_file = $mediawiki_path . '/maintenance/tables.sql'; $main_db = ForgeConfig::get('sys_dbname'); db_query('START TRANSACTION;'); try { $this->logger->info('Creating schema ' . $schema); $create_db = db_query_params('CREATE SCHEMA ' . $schema, array()); if (!$create_db) { throw new Exception('Error: Schema Creation Failed: ' . db_error()); } $this->logger->info('Updating mediawiki database.'); if (!file_exists($table_file)) { throw new Exception('Error: Couldn\'t find Mediawiki Database Creation File ' . $table_file); } $this->logger->info('Using schema: ' . $schema); $use_new_schema = db_query('USE ' . $schema); if (!$use_new_schema) { throw new Exception('Error: DB Query Failed: ' . db_error()); } $this->logger->info('Running db_query_from_file(' . $table_file . ')'); $add_tables = db_query_from_file($table_file); if (!$add_tables) { throw new Exception('Error: Mediawiki Database Creation Failed: ' . db_error()); } $this->logger->info('Updating list of mediawiki databases (' . $schema . ')'); db_query('USE ' . $main_db); $update = $this->dao->addDatabase($schema, $this->project_id); if (!$update) { throw new Exception('Error: Mediawiki Database list update failed: ' . mysql_error()); } } catch (Exception $e) { db_query('ROLLBACK;'); $this->logger->error($e->getMessage()); } db_query('COMMIT;'); $this->logger->info('Using schema: ' . $main_db); db_query('USE ' . $main_db); }
private function clearMediawikiCache(Project $project) { $schema = $this->getDao()->getMediawikiDatabaseName($project, false); $logger = new BackendLogger(); if ($schema) { $delete = $this->getDao()->clearPageCacheForSchema($schema); if (!$delete) { $logger->error('Project Clear cache: Can\'t delete mediawiki cache for schema: ' . $schema); } } else { $logger->error('Project Clear cache: Can\'t find mediawiki db for project: ' . $project->getID()); } }
* (at your option) any later version. * * Tuleap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Tuleap. If not, see <http://www.gnu.org/licenses/>. */ require_once 'pre.php'; require_once __DIR__ . '/../include/autoload.php'; $plugin_manager = PluginManager::instance(); $plugin = $plugin_manager->getPluginByName('proftpd'); if ($plugin && $plugin_manager->isPluginAvailable($plugin)) { $file_importer = new Tuleap\ProFTPd\Xferlog\FileImporter(new Tuleap\ProFTPd\Xferlog\Dao(), new Tuleap\ProFTPd\Xferlog\Parser(), UserManager::instance(), ProjectManager::instance(), $plugin->getPluginInfo()->getPropVal('proftpd_base_directory')); $file_importer->import($argv[1]); echo "{$file_importer->getNbImportedLines()} lines imported" . PHP_EOL; $errors = $file_importer->getErrors(); $nb_errors = count($errors); if ($nb_errors) { $logger = new BackendLogger(); echo "{$nb_errors} errors" . PHP_EOL; foreach ($errors as $error) { $logger->error('[Proftpd][xferlog parse] ' . $error); echo "*** ERROR: " . $error . PHP_EOL; } } } else { echo "*** ERROR: proftpd plugin not available" . PHP_EOL; }
* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Tuleap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Tuleap. If not, see <http://www.gnu.org/licenses/>. */ require 'pre.php'; $fd = fopen("php://stdin", "r"); $raw_mail = ""; while (!feof($fd)) { $raw_mail .= fread($fd, 1024); } fclose($fd); $logger = new BackendLogger(); $logger->info("Entering email gateway"); $recipient_factory = Tracker_Artifact_MailGateway_RecipientFactory::build(); $parser = new Tracker_Artifact_MailGateway_Parser($recipient_factory); $citation_sripper = new Tracker_Artifact_MailGateway_CitationStripper(); $mailgateway = new Tracker_Artifact_MailGateway_MailGateway($parser, $citation_sripper, $logger); try { $mailgateway->process($raw_mail); } catch (Exception $e) { $logger->error($e->getMessage()); } $logger->info("End email gateway");