No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Logger.php 5.8KB

hace 2 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Log\Handlers\FileHandler;
  4. use CodeIgniter\Config\BaseConfig;
  5. class Logger extends BaseConfig
  6. {
  7. /**
  8. * --------------------------------------------------------------------------
  9. * Error Logging Threshold
  10. * --------------------------------------------------------------------------
  11. *
  12. * You can enable error logging by setting a threshold over zero. The
  13. * threshold determines what gets logged. Any values below or equal to the
  14. * threshold will be logged.
  15. *
  16. * Threshold options are:
  17. *
  18. * - 0 = Disables logging, Error logging TURNED OFF
  19. * - 1 = Emergency Messages - System is unusable
  20. * - 2 = Alert Messages - Action Must Be Taken Immediately
  21. * - 3 = Critical Messages - Application component unavailable, unexpected exception.
  22. * - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
  23. * - 5 = Warnings - Exceptional occurrences that are not errors.
  24. * - 6 = Notices - Normal but significant events.
  25. * - 7 = Info - Interesting events, like user logging in, etc.
  26. * - 8 = Debug - Detailed debug information.
  27. * - 9 = All Messages
  28. *
  29. * You can also pass an array with threshold levels to show individual error types
  30. *
  31. * array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
  32. *
  33. * For a live site you'll usually enable Critical or higher (3) to be logged otherwise
  34. * your log files will fill up very fast.
  35. *
  36. * @var array|int
  37. */
  38. public $threshold = 4;
  39. /**
  40. * --------------------------------------------------------------------------
  41. * Date Format for Logs
  42. * --------------------------------------------------------------------------
  43. *
  44. * Each item that is logged has an associated date. You can use PHP date
  45. * codes to set your own date formatting
  46. *
  47. * @var string
  48. */
  49. public $dateFormat = 'Y-m-d H:i:s';
  50. /**
  51. * --------------------------------------------------------------------------
  52. * Log Handlers
  53. * --------------------------------------------------------------------------
  54. *
  55. * The logging system supports multiple actions to be taken when something
  56. * is logged. This is done by allowing for multiple Handlers, special classes
  57. * designed to write the log to their chosen destinations, whether that is
  58. * a file on the getServer, a cloud-based service, or even taking actions such
  59. * as emailing the dev team.
  60. *
  61. * Each handler is defined by the class name used for that handler, and it
  62. * MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
  63. *
  64. * The value of each key is an array of configuration items that are sent
  65. * to the constructor of each handler. The only required configuration item
  66. * is the 'handles' element, which must be an array of integer log levels.
  67. * This is most easily handled by using the constants defined in the
  68. * `Psr\Log\LogLevel` class.
  69. *
  70. * Handlers are executed in the order defined in this array, starting with
  71. * the handler on top and continuing down.
  72. *
  73. * @var array
  74. */
  75. public $handlers = [
  76. /*
  77. * --------------------------------------------------------------------
  78. * File Handler
  79. * --------------------------------------------------------------------
  80. */
  81. FileHandler::class => [
  82. // The log levels that this handler will handle.
  83. 'handles' => [
  84. 'critical',
  85. 'alert',
  86. 'emergency',
  87. 'debug',
  88. 'error',
  89. 'info',
  90. 'notice',
  91. 'warning',
  92. ],
  93. /*
  94. * The default filename extension for log files.
  95. * An extension of 'php' allows for protecting the log files via basic
  96. * scripting, when they are to be stored under a publicly accessible directory.
  97. *
  98. * Note: Leaving it blank will default to 'log'.
  99. */
  100. 'fileExtension' => '',
  101. /*
  102. * The file system permissions to be applied on newly created log files.
  103. *
  104. * IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
  105. * integer notation (i.e. 0700, 0644, etc.)
  106. */
  107. 'filePermissions' => 0644,
  108. /*
  109. * Logging Directory Path
  110. *
  111. * By default, logs are written to WRITEPATH . 'logs/'
  112. * Specify a different destination here, if desired.
  113. */
  114. 'path' => '',
  115. ],
  116. /*
  117. * The ChromeLoggerHandler requires the use of the Chrome web browser
  118. * and the ChromeLogger extension. Uncomment this block to use it.
  119. */
  120. // 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
  121. // /*
  122. // * The log levels that this handler will handle.
  123. // */
  124. // 'handles' => ['critical', 'alert', 'emergency', 'debug',
  125. // 'error', 'info', 'notice', 'warning'],
  126. // ],
  127. /*
  128. * The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
  129. * Uncomment this block to use it.
  130. */
  131. // 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
  132. // /* The log levels this handler can handle. */
  133. // 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
  134. //
  135. // /*
  136. // * The message type where the error should go. Can be 0 or 4, or use the
  137. // * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
  138. // */
  139. // 'messageType' => 0,
  140. // ],
  141. ];
  142. }