dblog.install 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the dblog module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function dblog_schema() {
  10. $schema['watchdog'] = array(
  11. 'description' => 'Table that contains logs of all system events.',
  12. 'fields' => array(
  13. 'wid' => array(
  14. 'type' => 'serial',
  15. 'not null' => TRUE,
  16. 'description' => 'Primary Key: Unique watchdog event ID.',
  17. ),
  18. 'uid' => array(
  19. 'type' => 'int',
  20. 'not null' => TRUE,
  21. 'default' => 0,
  22. 'description' => 'The {users}.uid of the user who triggered the event.',
  23. ),
  24. 'type' => array(
  25. 'type' => 'varchar',
  26. 'length' => 64,
  27. 'not null' => TRUE,
  28. 'default' => '',
  29. 'description' => 'Type of log message, for example "user" or "page not found."',
  30. ),
  31. 'message' => array(
  32. 'type' => 'text',
  33. 'not null' => TRUE,
  34. 'size' => 'big',
  35. 'description' => 'Text of log message to be passed into the t() function.',
  36. ),
  37. 'variables' => array(
  38. 'type' => 'blob',
  39. 'not null' => TRUE,
  40. 'size' => 'big',
  41. 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
  42. ),
  43. 'severity' => array(
  44. 'type' => 'int',
  45. 'unsigned' => TRUE,
  46. 'not null' => TRUE,
  47. 'default' => 0,
  48. 'size' => 'tiny',
  49. 'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
  50. ),
  51. 'link' => array(
  52. 'type' => 'varchar',
  53. 'length' => 255,
  54. 'not null' => FALSE,
  55. 'default' => '',
  56. 'description' => 'Link to view the result of the event.',
  57. ),
  58. 'location' => array(
  59. 'type' => 'text',
  60. 'not null' => TRUE,
  61. 'description' => 'URL of the origin of the event.',
  62. ),
  63. 'referer' => array(
  64. 'type' => 'text',
  65. 'not null' => FALSE,
  66. 'description' => 'URL of referring page.',
  67. ),
  68. 'hostname' => array(
  69. 'type' => 'varchar',
  70. 'length' => 128,
  71. 'not null' => TRUE,
  72. 'default' => '',
  73. 'description' => 'Hostname of the user who triggered the event.',
  74. ),
  75. 'timestamp' => array(
  76. 'type' => 'int',
  77. 'not null' => TRUE,
  78. 'default' => 0,
  79. 'description' => 'Unix timestamp of when event occurred.',
  80. ),
  81. ),
  82. 'primary key' => array('wid'),
  83. 'indexes' => array(
  84. 'type' => array('type'),
  85. 'uid' => array('uid'),
  86. ),
  87. );
  88. return $schema;
  89. }
  90. /**
  91. * Implements hook_uninstall().
  92. */
  93. function dblog_uninstall() {
  94. variable_del('dblog_row_limit');
  95. }
  96. /**
  97. * @addtogroup updates-6.x-to-7.x
  98. * @{
  99. */
  100. /**
  101. * Update the {watchdog} table.
  102. */
  103. function dblog_update_7001() {
  104. // Allow NULL values for links.
  105. db_change_field('watchdog', 'link', 'link', array(
  106. 'type' => 'varchar',
  107. 'length' => 255,
  108. 'not null' => FALSE,
  109. 'default' => '',
  110. 'description' => 'Link to view the result of the event.',
  111. ));
  112. // Add an index on uid.
  113. db_add_index('watchdog', 'uid', array('uid'));
  114. // Allow longer type values.
  115. db_change_field('watchdog', 'type', 'type', array(
  116. 'type' => 'varchar',
  117. 'length' => 64,
  118. 'not null' => TRUE,
  119. 'default' => '',
  120. 'description' => 'Type of log message, for example "user" or "page not found."',
  121. ));
  122. // Convert the variables field (that stores serialized variables) from text to blob.
  123. db_change_field('watchdog', 'variables', 'variables', array(
  124. 'type' => 'blob',
  125. 'not null' => TRUE,
  126. 'size' => 'big',
  127. 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
  128. ));
  129. }
  130. /**
  131. * @} End of "addtogroup updates-6.x-to-7.x".
  132. */