Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #7 from PiwikPRO/logger-refactoring
Browse files Browse the repository at this point in the history
Logger refactoring in Piwik 2.10
  • Loading branch information
mnapoli committed Dec 21, 2014
2 parents e2c4281 + 14b7068 commit bc0b785
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 33 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ php:
- 5.3.3
# - hhvm

services:
- redis-server

# Separate different test suites
env:
global:
Expand Down Expand Up @@ -79,6 +82,9 @@ before_script:
phpenv config-rm xdebug.ini;
fi

# add always_populate_raw_post_data=-1 to php.ini
- echo "always_populate_raw_post_data=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

- ./tests/travis/configure_git.sh

# print out mysql information
Expand All @@ -88,8 +94,6 @@ before_script:
# configure mysql
- mysql -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'" # Travis default

# Uncomment to enable sql_mode STRICT_TRANS_TABLES (new default in Mysql 5.6)
- mysql -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION'"
- mysql -e "SELECT @@sql_mode;"
- mysql -e "SHOW GLOBAL VARIABLES;"

Expand Down
22 changes: 3 additions & 19 deletions Commands/MigrateSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$config = Db::getDatabaseConfig();
$startTime = microtime(true);

try {
$this->createTargetDatabaseConfig($input, $output, $config);
} catch (\InvalidArgumentException $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return;
}
$this->createTargetDatabaseConfig($input, $output, $config);

$tmpConfig = $config;
$sourceDb = Db::get();
Expand All @@ -89,14 +84,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \RuntimeException('Unable to connect to the target database: ' . $e->getMessage(), 0, $e);
}

if ($output->getVerbosity() == OutputInterface::VERBOSITY_VERBOSE) {
Log::getInstance()->setLogLevel(Log::INFO);
}

if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
Log::getInstance()->setLogLevel(Log::VERBOSE);
}

$sourceDbHelper = new DBHelper($sourceDb, Db::getDatabaseConfig());

$migratorFacade = new Migrator(
Expand All @@ -111,11 +98,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

$endTime = microtime(true);

$output->writeln(sprintf(PHP_EOL . '<comment>Time taken: %01.2f sec</comment>', $endTime - $startTime));
$output->writeln(sprintf(
'<comment>Peak memory usage: %01.2f MB</comment>',
memory_get_peak_usage(true) / 1048576
));
Log::debug(sprintf('Time taken: %01.2f sec', $endTime - $startTime));
Log::debug(sprintf('Peak memory usage: %01.2f MB', memory_get_peak_usage(true) / 1048576));
}


Expand Down
2 changes: 1 addition & 1 deletion Migrator/ArchiveMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function migrate($siteId, \DateTime $from = null, \DateTime $to = null)
$archives = $this->archiveLister->getArchiveList($from, $to);

foreach ($archives as $archiveDate) {
Log::info('Migrating archive ' . $archiveDate);
Log::debug('Migrating archive ' . $archiveDate);

$this->migrateArchive($archiveDate, 'archive_numeric_' . $archiveDate, $siteId);

Expand Down
16 changes: 8 additions & 8 deletions Migrator/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ public function migrate()

private function startTransaction()
{
Log::warning('Start transaction');
Log::info('Start transaction');
$this->targetDbHelper->startTransaction();
}

private function commitTransaction()
{
Log::warning('Commit transaction');
Log::info('Commit transaction');
$this->targetDbHelper->commitTransaction();
}

private function migrateSiteConfig()
{
Log::warning('Migrating site config');
Log::info('Migrating site config');

$this->siteMigrator->migrate(
$this->getBatchProvider(
Expand All @@ -158,14 +158,14 @@ private function migrateSiteConfig()

private function loadActions()
{
Log::warning('Loading existing actions');
Log::info('Loading existing actions');

$this->actionMigrator->loadExistingActions();
}

private function migrateLogVisits()
{
Log::warning('Migrating log data - visits');
Log::info('Migrating log data - visits');

$query = 'SELECT * FROM ' . $this->sourceDbHelper->prefixTable('log_visit') . ' WHERE idsite = ' . $this->settings->idSite;

Expand All @@ -184,7 +184,7 @@ private function migrateLogVisits()

private function migrateLogVisitActions()
{
Log::warning('Migrating log data - link visit action');
Log::info('Migrating log data - link visit action');

$queries = $this->getLogVisitQueriesFor('log_link_visit_action');

Expand All @@ -195,7 +195,7 @@ private function migrateLogVisitActions()

private function migrateLogVisitConversions()
{
Log::warning('Migrating log data - conversions and conversion items');
Log::info('Migrating log data - conversions and conversion items');

$queries = $this->getLogVisitQueriesFor('log_conversion');
$itemQueries = $this->getLogVisitQueriesFor('log_conversion_item');
Expand All @@ -208,7 +208,7 @@ private function migrateLogVisitConversions()

private function migrateArchives()
{
Log::warning('Migrating archive data');
Log::info('Migrating archive data');

$this->archiveMigrator->migrate($this->settings->idSite, $this->settings->dateFrom, $this->settings->dateTo);
}
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ No, you must run the command from the source Piwik server (the server which cont

## Changelog

**v1.0.5**
**v1.0.7**

- Updated the plugin for compatibility with Piwik 2.10.

**v1.0.6**

- [#6](https://github.com/PiwikPRO/plugin-SiteMigration/issues/6): fixed a PHP 5.3 incompatibility

Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SiteMigration",
"version": "1.0.6",
"version": "1.0.7",
"description": "Migrate site and site data between Piwik installations",
"keywords": ["migration", "import", "export"],
"homepage": "https://github.com/PiwikPRO/plugin-SiteMigration",
Expand All @@ -9,7 +9,7 @@
"license_page": "http://www.gnu.org/licenses/gpl.html",
"require": {
"php": ">=5.3.0",
"piwik": ">=2.9.1"
"piwik": ">=2.10.0-b10"
},
"authors": [
{
Expand Down

0 comments on commit bc0b785

Please sign in to comment.