error.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. return array(
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Error Detail
  6. |--------------------------------------------------------------------------
  7. |
  8. | Detailed error messages contain information about the file in which
  9. | an error occurs, a stack trace, and a snapshot of the source code
  10. | in which the error occured.
  11. |
  12. | If your application is in production, consider turning off error details
  13. | for enhanced security and user experience.
  14. |
  15. */
  16. 'detail' => true,
  17. /*
  18. |--------------------------------------------------------------------------
  19. | Error Logging
  20. |--------------------------------------------------------------------------
  21. |
  22. | Error Logging will use the "logger" function defined below to log error
  23. | messages, which gives you complete freedom to determine how error
  24. | messages are logged. Enjoy the flexibility.
  25. |
  26. */
  27. 'log' => false,
  28. /*
  29. |--------------------------------------------------------------------------
  30. | Error Handler
  31. |--------------------------------------------------------------------------
  32. |
  33. | Because of the various ways of managing error logging, you get complete
  34. | flexibility in Laravel to manage error logging as you see fit.
  35. |
  36. | This function will be called when an error occurs in your application.
  37. | You can log the error however you like.
  38. |
  39. | The error "severity" passed to the method is a human-readable severity
  40. | level such as "Parsing Error" or "Fatal Error".
  41. |
  42. | A simple logging system has been setup for you. By default, all errors
  43. | will be logged to the storage/log.txt file.
  44. |
  45. */
  46. 'handler' => function($exception, $severity, $message, $config)
  47. {
  48. if ($config['detail'])
  49. {
  50. $data = compact('exception', 'severity', 'message');
  51. $response = Response::view('error.exception', $data)->status(500);
  52. }
  53. else
  54. {
  55. $response = Response::error('500');
  56. }
  57. if ($config['log'])
  58. {
  59. call_user_func($config['logger'], $severity, $message);
  60. }
  61. $response->send();
  62. exit(1);
  63. },
  64. /*
  65. |--------------------------------------------------------------------------
  66. | Error Logger
  67. |--------------------------------------------------------------------------
  68. |
  69. | Because of the various ways of managing error logging, you get complete
  70. | flexibility to manage error logging as you see fit.
  71. |
  72. | This function will be called when an error occurs in your application.
  73. | You can log the error however you like.
  74. |
  75. | The error "severity" passed to the method is a human-readable severity
  76. | level such as "Parsing Error" or "Fatal Error".
  77. |
  78. | A simple logging system has been setup for you. By default, all errors
  79. | will be logged to the storage/log.txt file.
  80. |
  81. */
  82. 'logger' => function($severity, $message)
  83. {
  84. File::append(STORAGE_PATH.'log.txt', date('Y-m-d H:i:s').' '.$severity.' - '.$message.PHP_EOL);
  85. }
  86. );