Monolog log rotation in dev environment. Console command logging updated.
This commit is contained in:
parent
2f4a83d366
commit
30faaa7b08
|
@ -21,6 +21,8 @@ monolog:
|
||||||
channels: [!event]
|
channels: [!event]
|
||||||
console:
|
console:
|
||||||
type: console
|
type: console
|
||||||
|
verbosity_levels:
|
||||||
|
VERBOSITY_NORMAL: INFO
|
||||||
channels: [!event, !doctrine]
|
channels: [!event, !doctrine]
|
||||||
# uncomment to get logging in your browser
|
# uncomment to get logging in your browser
|
||||||
# you may have to allow bigger header sizes in your Web server configuration
|
# you may have to allow bigger header sizes in your Web server configuration
|
||||||
|
|
|
@ -46,7 +46,7 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
|
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
$userRepository = $em->getRepository('SkobkinPointToolsBundle:User');
|
$userRepository = $em->getRepository('SkobkinPointToolsBundle:User');
|
||||||
|
|
||||||
$log->info('UpdateSubscriptionsCommand started.');
|
$log->debug('UpdateSubscriptionsCommand started.');
|
||||||
|
|
||||||
/** @var UserApi $api */
|
/** @var UserApi $api */
|
||||||
$api = $this->getContainer()->get('app.point.api_user');
|
$api = $this->getContainer()->get('app.point.api_user');
|
||||||
|
@ -75,15 +75,21 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
|
$log->info('Getting service subscribers');
|
||||||
$output->writeln('Getting service subscribers');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$usersForUpdate = $api->getUserSubscribersById($serviceUserId);
|
$usersForUpdate = $api->getUserSubscribersById($serviceUserId);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$output->writeln('Error while getting service subscribers');
|
$log->warning(
|
||||||
$log->error('Error while getting service subscribers.', ['user_login' => $serviceUser->getLogin(), 'user_id' => $serviceUser->getId(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
|
'Error while getting service subscribers. Fallback to local list.',
|
||||||
|
[
|
||||||
|
'user_login' => $serviceUser->getLogin(),
|
||||||
|
'user_id' => $serviceUser->getId(),
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'line' => $e->getLine()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
$usersForUpdate = [];
|
$usersForUpdate = [];
|
||||||
|
|
||||||
|
@ -91,56 +97,72 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
$usersForUpdate[] = $subscription->getSubscriber();
|
$usersForUpdate[] = $subscription->getSubscriber();
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln('Fallback to local list');
|
|
||||||
$log->error('Fallback to local list');
|
|
||||||
|
|
||||||
if (!count($usersForUpdate)) {
|
if (!count($usersForUpdate)) {
|
||||||
$log->info('No local subscribers. Finishing.');
|
$log->info('No local subscribers. Finishing.');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
|
$log->debug('Updating service subscribers');
|
||||||
$output->writeln('Updating service subscribers');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updating service subscribers
|
// Updating service subscribers
|
||||||
try {
|
try {
|
||||||
$subscriptionsManager->updateUserSubscribers($serviceUser, $usersForUpdate);
|
$subscriptionsManager->updateUserSubscribers($serviceUser, $usersForUpdate);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$log->error('Error while updating service subscribers', ['user_login' => $serviceUser->getLogin(), 'user_id' => $serviceUser->getId(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
|
$log->error(
|
||||||
|
'Error while updating service subscribers',
|
||||||
|
[
|
||||||
|
'user_login' => $serviceUser->getLogin(),
|
||||||
|
'user_id' => $serviceUser->getId(),
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'line' => $e->getLine()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
|
$log->info('Processing users subscribers');
|
||||||
$output->writeln('Processing users subscribers');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updating users subscribers
|
// Updating users subscribers
|
||||||
foreach ($usersForUpdate as $user) {
|
foreach ($usersForUpdate as $user) {
|
||||||
$output->writeln(' Processing @' . $user->getLogin());
|
|
||||||
$log->info('Processing @'.$user->getLogin());
|
$log->info('Processing @'.$user->getLogin());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userCurrentSubscribers = $api->getUserSubscribersById($user->getId());
|
$userCurrentSubscribers = $api->getUserSubscribersById($user->getId());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$output->writeln(' Error while getting subscribers. Skipping.');
|
$log->error(
|
||||||
$log->error('Error while getting subscribers.', ['user_login' => $user->getLogin(), 'user_id' => $user->getId(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
|
'Error while getting subscribers. Skipping.',
|
||||||
|
[
|
||||||
|
'user_login' => $user->getLogin(),
|
||||||
|
'user_id' => $user->getId(),
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'line' => $e->getLine()
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) {
|
$log->debug('Updating user subscribers');
|
||||||
$output->writeln(' Updating user subscribers');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Updating user subscribers
|
// Updating user subscribers
|
||||||
$subscriptionsManager->updateUserSubscribers($user, $userCurrentSubscribers);
|
$subscriptionsManager->updateUserSubscribers($user, $userCurrentSubscribers);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$log->error('Error while updating user subscribers', ['user_login' => $user->getLogin(), 'user_id' => $user->getId(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
|
$log->error(
|
||||||
|
'Error while updating user subscribers',
|
||||||
|
[
|
||||||
|
'user_login' => $user->getLogin(),
|
||||||
|
'user_id' => $user->getId(),
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'line' => $e->getLine()
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @todo move to the config
|
// @todo move to the config
|
||||||
|
@ -151,6 +173,8 @@ class UpdateSubscriptionsCommand extends ContainerAwareCommand
|
||||||
$em->flush();
|
$em->flush();
|
||||||
$em->commit();
|
$em->commit();
|
||||||
|
|
||||||
|
$log->debug('Finished');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue