DebugPDO.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * This file is part of the Propel package.
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * @license MIT License
  8. */
  9. /**
  10. * PDO connection subclass that provides some basic support for query counting and logging.
  11. *
  12. * This class is ONLY intended for development use. This class is also a work in-progress
  13. * and, as such, it should be expected that this class' API may change.
  14. *
  15. * The following runtime configuration items affect the behaviour of this class:
  16. *
  17. * - debugpdo.logging.enabled (default: true)
  18. * Should any logging take place
  19. *
  20. * - debugpdo.logging.innerglue (default: ": ")
  21. * String to use for combining the title of a detail and its value
  22. *
  23. * - debugpdo.logging.outerglue (default: " | ")
  24. * String to use for combining details together on a log line
  25. *
  26. * - debugpdo.logging.realmemoryusage (default: false)
  27. * Parameter to memory_get_usage() and memory_get_peak_usage() calls
  28. *
  29. * - debugpdo.logging.methods (default: DebugPDO::$defaultLogMethods)
  30. * An array of method names ("Class::method") to be included in method call logging
  31. *
  32. * - debugpdo.logging.onlyslow (default: false)
  33. * Suppress logging of non-slow queries.
  34. *
  35. * - debugpdo.logging.details.slow.enabled (default: false)
  36. * Enables flagging of slow method calls
  37. *
  38. * - debugpdo.logging.details.slow.threshold (default: 0.1)
  39. * Method calls taking more seconds than this threshold are considered slow
  40. *
  41. * - debugpdo.logging.details.time.enabled (default: false)
  42. * Enables logging of method execution times
  43. *
  44. * - debugpdo.logging.details.time.precision (default: 3)
  45. * Determines the precision of the execution time logging
  46. *
  47. * - debugpdo.logging.details.time.pad (default: 10)
  48. * How much horizontal space to reserve for the execution time on a log line
  49. *
  50. * - debugpdo.logging.details.mem.enabled (default: false)
  51. * Enables logging of the instantaneous PHP memory consumption
  52. *
  53. * - debugpdo.logging.details.mem.precision (default: 1)
  54. * Determines the precision of the memory consumption logging
  55. *
  56. * - debugpdo.logging.details.mem.pad (default: 9)
  57. * How much horizontal space to reserve for the memory consumption on a log line
  58. *
  59. * - debugpdo.logging.details.memdelta.enabled (default: false)
  60. * Enables logging differences in memory consumption before and after the method call
  61. *
  62. * - debugpdo.logging.details.memdelta.precision (default: 1)
  63. * Determines the precision of the memory difference logging
  64. *
  65. * - debugpdo.logging.details.memdelta.pad (default: 10)
  66. * How much horizontal space to reserve for the memory difference on a log line
  67. *
  68. * - debugpdo.logging.details.mempeak.enabled (default: false)
  69. * Enables logging the peak memory consumption thus far by the currently executing PHP script
  70. *
  71. * - debugpdo.logging.details.mempeak.precision (default: 1)
  72. * Determines the precision of the memory peak logging
  73. *
  74. * - debugpdo.logging.details.mempeak.pad (default: 9)
  75. * How much horizontal space to reserve for the memory peak on a log line
  76. *
  77. * - debugpdo.logging.details.querycount.enabled (default: false)
  78. * Enables logging of the number of queries performed by the DebugPDO instance thus far
  79. *
  80. * - debugpdo.logging.details.querycount.pad (default: 2)
  81. * How much horizontal space to reserve for the query count on a log line
  82. *
  83. * - debugpdo.logging.details.method.enabled (default: false)
  84. * Enables logging of the name of the method call
  85. *
  86. * - debugpdo.logging.details.method.pad (default: 28)
  87. * How much horizontal space to reserve for the method name on a log line
  88. *
  89. * The order in which the logging details are enabled is significant, since it determines the order in
  90. * which they will appear in the log file.
  91. *
  92. * @example // Enable simple query profiling, flagging calls taking over 1.5 seconds as slow:
  93. * $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
  94. * $config->setParameter('debugpdo.logging.details.slow.enabled', true);
  95. * $config->setParameter('debugpdo.logging.details.slow.threshold', 1.5);
  96. * $config->setParameter('debugpdo.logging.details.time.enabled', true);
  97. *
  98. * @author Francois Zaninotto
  99. * @author Cameron Brunner <cameron.brunner@gmail.com>
  100. * @author Hans Lellelid <hans@xmpl.org>
  101. * @author Christian Abegg <abegg.ch@gmail.com>
  102. * @author Jarno Rantanen <jarno.rantanen@tkk.fi>
  103. * @since 2006-09-22
  104. * @package propel.runtime.connection
  105. */
  106. class DebugPDO extends PropelPDO
  107. {
  108. public $useDebug = true;
  109. }