Skip to content

Commit 5d9b47f

Browse files
committed
Migliorata la stampa dell'errore in caso di validazione errata con tutti gli attributi del model prima faceva tante entry nel log adesso un unica entry che con sistemi tipo logViewer si legge meglio e se mandiamo ad un servizio in cloud conta una sola request anzichè n request.
1 parent 14b7cd0 commit 5d9b47f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Validable.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,18 @@ public function validate()
6868
$this->setErrors($v->messages());
6969

7070
if (config('laravel-validable.debug')) {
71-
Log::debug('Errore durante la validazione del model \'' . $this->getTable() . '\' in \'' . ($this->id > 0 ? 'update' : 'create') . '\' lanciato su evento saving del model.');
72-
Log::debug('Attributi del model:');
73-
Log::debug($this->toJson(JSON_PRETTY_PRINT));
74-
Log::debug('Errori di validazione:');
75-
Log::debug($this->getErrors());
76-
Log::debug('StackTrace:'.PHP_EOL);
71+
$msg = 'Errore durante la validazione del model \'' . $this->getTable() . '\' in \'' . ($this->id > 0 ? 'update' : 'create') . '\' lanciato su evento saving del model.';
72+
$msg .= 'Attributi del model:';
73+
$msg .= $this->toJson(JSON_PRETTY_PRINT);
74+
$msg .= 'Errori di validazione:';
75+
$msg .= $this->getErrors();
76+
$msg .= 'StackTrace:'.PHP_EOL;
7777
ob_start();
7878
debug_print_backtrace();
7979
$StackTrace = ob_get_contents();
8080
ob_end_clean();
81-
Log::debug($StackTrace);
81+
$msg .= $StackTrace;
82+
Log::debug($msg);
8283
}
8384

8485
return false;

0 commit comments

Comments
 (0)