mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Replace log.
This commit is contained in:
@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddsTransactionIdentifiers extends Command
|
||||
@@ -147,7 +148,7 @@ class AddsTransactionIdentifiers extends Command
|
||||
->first()
|
||||
;
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
$this->friendlyError('Firefly III could not find the "identifier" field in the "transactions" table.');
|
||||
$this->friendlyError(sprintf('This field is required for Firefly III version %s to run.', config('firefly.version')));
|
||||
$this->friendlyError('Please run "php artisan migrate --force" to add this field to the table.');
|
||||
|
@@ -31,6 +31,7 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use JsonException;
|
||||
use stdClass;
|
||||
|
||||
@@ -96,7 +97,7 @@ class RemovesDatabaseDecryption extends Command
|
||||
try {
|
||||
$configVar = app('fireflyconfig')->get($configName, false);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
if (null !== $configVar) {
|
||||
return (bool) $configVar->data;
|
||||
@@ -129,8 +130,8 @@ class RemovesDatabaseDecryption extends Command
|
||||
} catch (FireflyException $e) {
|
||||
$message = sprintf('Could not decrypt field "%s" in row #%d of table "%s": %s', $field, $id, $table, $e->getMessage());
|
||||
$this->friendlyError($message);
|
||||
app('log')->error($message);
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($message);
|
||||
Log::error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
// A separate routine for preferences table:
|
||||
@@ -175,9 +176,9 @@ class RemovesDatabaseDecryption extends Command
|
||||
} catch (JsonException $e) {
|
||||
$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());
|
||||
$this->friendlyError($message);
|
||||
app('log')->warning($message);
|
||||
app('log')->warning($value);
|
||||
app('log')->warning($e->getTraceAsString());
|
||||
Log::warning($message);
|
||||
Log::warning($value);
|
||||
Log::warning($e->getTraceAsString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Note;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesAttachments extends Command
|
||||
{
|
||||
@@ -75,7 +76,7 @@ class UpgradesAttachments extends Command
|
||||
$att->description = '';
|
||||
$att->save();
|
||||
|
||||
app('log')->debug(sprintf('Migrated attachment #%s description to note #%d.', $att->id, $note->id));
|
||||
Log::debug(sprintf('Migrated attachment #%s description to note #%d.', $att->id, $note->id));
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\Upgrade;
|
||||
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesBudgetLimitPeriods extends Command
|
||||
{
|
||||
@@ -84,7 +85,7 @@ class UpgradesBudgetLimitPeriods extends Command
|
||||
$limit->end_date->format('Y-m-d')
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
app('log')->warning($message);
|
||||
Log::warning($message);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +99,7 @@ class UpgradesBudgetLimitPeriods extends Command
|
||||
$limit->end_date->format('Y-m-d'),
|
||||
$period
|
||||
);
|
||||
app('log')->debug($msg);
|
||||
Log::debug($msg);
|
||||
}
|
||||
|
||||
private function getLimitPeriod(BudgetLimit $limit): ?string
|
||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournalMeta;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesJournalNotes extends Command
|
||||
{
|
||||
@@ -66,7 +67,7 @@ class UpgradesJournalNotes extends Command
|
||||
|
||||
$note->text = $meta->data;
|
||||
$note->save();
|
||||
app('log')->debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
|
||||
Log::debug(sprintf('Migrated meta note #%d to Note #%d', $meta->id, $note->id));
|
||||
$meta->delete();
|
||||
|
||||
++$count;
|
||||
|
@@ -35,6 +35,7 @@ use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
|
||||
use FireflyIII\Services\Internal\Support\CreditRecalculateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesLiabilitiesEight extends Command
|
||||
{
|
||||
@@ -186,7 +187,7 @@ class UpgradesLiabilitiesEight extends Command
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->warning('Did not find opening balance.');
|
||||
Log::warning('Did not find opening balance.');
|
||||
}
|
||||
|
||||
private function deleteTransactions(Account $account): int
|
||||
|
@@ -38,6 +38,7 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesToGroups extends Command
|
||||
{
|
||||
@@ -127,11 +128,11 @@ class UpgradesToGroups extends Command
|
||||
{
|
||||
// double check transaction count.
|
||||
if ($journal->transactions->count() <= 2) {
|
||||
app('log')->debug(sprintf('Will not try to convert journal #%d because it has 2 or fewer transactions.', $journal->id));
|
||||
Log::debug(sprintf('Will not try to convert journal #%d because it has 2 or fewer transactions.', $journal->id));
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->debug(sprintf('Will now try to convert journal #%d', $journal->id));
|
||||
Log::debug(sprintf('Will now try to convert journal #%d', $journal->id));
|
||||
|
||||
$this->journalRepository->setUser($journal->user);
|
||||
$this->groupFactory->setUser($journal->user);
|
||||
@@ -144,15 +145,15 @@ class UpgradesToGroups extends Command
|
||||
];
|
||||
$destTransactions = $this->getDestinationTransactions($journal);
|
||||
|
||||
app('log')->debug(sprintf('Will use %d positive transactions to create a new group.', $destTransactions->count()));
|
||||
Log::debug(sprintf('Will use %d positive transactions to create a new group.', $destTransactions->count()));
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($destTransactions as $transaction) {
|
||||
$data['transactions'][] = $this->generateTransaction($journal, $transaction);
|
||||
}
|
||||
app('log')->debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
|
||||
Log::debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));
|
||||
$group = $this->groupFactory->create($data);
|
||||
app('log')->debug('Done calling transaction journal factory');
|
||||
Log::debug('Done calling transaction journal factory');
|
||||
|
||||
// delete the old transaction journal.
|
||||
$this->service->destroy($journal);
|
||||
@@ -160,7 +161,7 @@ class UpgradesToGroups extends Command
|
||||
++$this->count;
|
||||
|
||||
// report on result:
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf(
|
||||
'Migrated journal #%d into group #%d with these journals: #%s',
|
||||
$journal->id,
|
||||
@@ -190,7 +191,7 @@ class UpgradesToGroups extends Command
|
||||
*/
|
||||
private function generateTransaction(TransactionJournal $journal, Transaction $transaction): array
|
||||
{
|
||||
app('log')->debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
|
||||
Log::debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
|
||||
$opposingTr = $this->findOpposingTransaction($journal, $transaction);
|
||||
|
||||
if (!$opposingTr instanceof Transaction) {
|
||||
@@ -282,8 +283,8 @@ class UpgradesToGroups extends Command
|
||||
static function (Transaction $subject) use ($transaction) {
|
||||
$amount = (float) $transaction->amount * -1 === (float) $subject->amount; // intentional float
|
||||
$identifier = $transaction->identifier === $subject->identifier;
|
||||
app('log')->debug(sprintf('Amount the same? %s', var_export($amount, true)));
|
||||
app('log')->debug(sprintf('ID the same? %s', var_export($identifier, true)));
|
||||
Log::debug(sprintf('Amount the same? %s', var_export($amount, true)));
|
||||
Log::debug(sprintf('ID the same? %s', var_export($identifier, true)));
|
||||
|
||||
return $amount && $identifier;
|
||||
}
|
||||
@@ -294,13 +295,13 @@ class UpgradesToGroups extends Command
|
||||
|
||||
private function getTransactionBudget(Transaction $left, Transaction $right): ?int
|
||||
{
|
||||
app('log')->debug('Now in getTransactionBudget()');
|
||||
Log::debug('Now in getTransactionBudget()');
|
||||
|
||||
// try to get a budget ID from the left transaction:
|
||||
/** @var null|Budget $budget */
|
||||
$budget = $left->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
|
||||
|
||||
return $budget->id;
|
||||
}
|
||||
@@ -309,11 +310,11 @@ class UpgradesToGroups extends Command
|
||||
/** @var null|Budget $budget */
|
||||
$budget = $right->budgets()->first();
|
||||
if (null !== $budget) {
|
||||
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
|
||||
Log::debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
|
||||
|
||||
return $budget->id;
|
||||
}
|
||||
app('log')->debug('Neither left or right have a budget, return NULL');
|
||||
Log::debug('Neither left or right have a budget, return NULL');
|
||||
|
||||
// if all fails, return NULL.
|
||||
return null;
|
||||
@@ -321,13 +322,13 @@ class UpgradesToGroups extends Command
|
||||
|
||||
private function getTransactionCategory(Transaction $left, Transaction $right): ?int
|
||||
{
|
||||
app('log')->debug('Now in getTransactionCategory()');
|
||||
Log::debug('Now in getTransactionCategory()');
|
||||
|
||||
// try to get a category ID from the left transaction:
|
||||
/** @var null|Category $category */
|
||||
$category = $left->categories()->first();
|
||||
if (null !== $category) {
|
||||
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
|
||||
|
||||
return $category->id;
|
||||
}
|
||||
@@ -336,11 +337,11 @@ class UpgradesToGroups extends Command
|
||||
/** @var null|Category $category */
|
||||
$category = $right->categories()->first();
|
||||
if (null !== $category) {
|
||||
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
|
||||
Log::debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
|
||||
|
||||
return $category->id;
|
||||
}
|
||||
app('log')->debug('Neither left or right have a category, return NULL');
|
||||
Log::debug('Neither left or right have a category, return NULL');
|
||||
|
||||
// if all fails, return NULL.
|
||||
return null;
|
||||
@@ -354,7 +355,7 @@ class UpgradesToGroups extends Command
|
||||
$orphanedJournals = $this->cliRepository->getJournalsWithoutGroup();
|
||||
$total = count($orphanedJournals);
|
||||
if ($total > 0) {
|
||||
app('log')->debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
$this->friendlyInfo(sprintf('Going to convert %d transaction journals. Please hold..', $total));
|
||||
|
||||
/** @var array $array */
|
||||
|
@@ -33,6 +33,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpgradesTransferCurrencies extends Command
|
||||
{
|
||||
@@ -262,7 +263,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
// source account must have a currency preference.
|
||||
if (!$this->sourceCurrency instanceof TransactionCurrency) {
|
||||
$message = sprintf('Account #%d ("%s") must have currency preference but has none.', $this->sourceAccount->id, $this->sourceAccount->name);
|
||||
app('log')->error($message);
|
||||
Log::error($message);
|
||||
$this->friendlyError($message);
|
||||
|
||||
return true;
|
||||
@@ -275,7 +276,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
$this->destinationAccount->id,
|
||||
$this->destinationAccount->name
|
||||
);
|
||||
app('log')->error($message);
|
||||
Log::error($message);
|
||||
$this->friendlyError($message);
|
||||
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user