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