126 lines
3.4 KiB
Plaintext
126 lines
3.4 KiB
Plaintext
<?php
|
|
// $Id$
|
|
|
|
/**
|
|
* Implementation of hook_install().
|
|
*/
|
|
function dblog_install() {
|
|
// Create tables.
|
|
drupal_install_schema('dblog');
|
|
}
|
|
|
|
/**
|
|
* Implementation of hook_uninstall().
|
|
*/
|
|
function dblog_uninstall() {
|
|
// Remove tables.
|
|
drupal_uninstall_schema('dblog');
|
|
}
|
|
|
|
/**
|
|
* Implementation of hook_schema().
|
|
*/
|
|
function dblog_schema() {
|
|
$schema['watchdog'] = array(
|
|
'description' => t('Table that contains logs of all system events.'),
|
|
'fields' => array(
|
|
'wid' => array(
|
|
'type' => 'serial',
|
|
'not null' => TRUE,
|
|
'description' => t('Primary Key: Unique watchdog event ID.'),
|
|
),
|
|
'uid' => array(
|
|
'type' => 'int',
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'description' => t('The {users}.uid of the user who triggered the event.'),
|
|
),
|
|
'type' => array(
|
|
'type' => 'varchar',
|
|
'length' => 16,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => t('Type of log message, for example "user" or "page not found."'),
|
|
),
|
|
'message' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'size' => 'big',
|
|
'description' => t('Text of log message to be passed into the t() function.'),
|
|
),
|
|
'variables' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'size' => 'big',
|
|
'description' => t('Serialized array of variables that match the message string and that is passed into the t() function.'),
|
|
),
|
|
'severity' => array(
|
|
'type' => 'int',
|
|
'unsigned' => TRUE,
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'size' => 'tiny',
|
|
'description' => t('The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)'),
|
|
),
|
|
'link' => array(
|
|
'type' => 'varchar',
|
|
'length' => 255,
|
|
'not null' => FALSE,
|
|
'default' => '',
|
|
'description' => t('Link to view the result of the event.'),
|
|
),
|
|
'location' => array(
|
|
'type' => 'text',
|
|
'not null' => TRUE,
|
|
'description' => t('URL of the origin of the event.'),
|
|
),
|
|
'referer' => array(
|
|
'type' => 'varchar',
|
|
'length' => 128,
|
|
'not null' => FALSE,
|
|
'default' => '',
|
|
'description' => t('URL of referring page.'),
|
|
),
|
|
'hostname' => array(
|
|
'type' => 'varchar',
|
|
'length' => 128,
|
|
'not null' => TRUE,
|
|
'default' => '',
|
|
'description' => t('Hostname of the user who triggered the event.'),
|
|
),
|
|
'timestamp' => array(
|
|
'type' => 'int',
|
|
'not null' => TRUE,
|
|
'default' => 0,
|
|
'description' => t('Unix timestamp of when event occurred.'),
|
|
),
|
|
),
|
|
'primary key' => array('wid'),
|
|
'indexes' => array(
|
|
'type' => array('type'),
|
|
'uid' => array('uid'),
|
|
),
|
|
);
|
|
|
|
return $schema;
|
|
}
|
|
|
|
/**
|
|
* Allow NULL values for links.
|
|
*/
|
|
function dblog_update_7001() {
|
|
$ret = array();
|
|
db_change_field($ret, 'watchdog', 'link', 'link', array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''));
|
|
db_change_field($ret, 'watchdog', 'referer', 'referer', array('type' => 'varchar', 'length' => 255, 'not null' => FALSE, 'default' => ''));
|
|
return $ret;
|
|
}
|
|
|
|
/**
|
|
* Add index on uid.
|
|
*/
|
|
function dblog_update_7002() {
|
|
$ret = array();
|
|
db_add_index($ret, 'watchdog', 'uid', array('uid'));
|
|
return $ret;
|
|
}
|