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