forked from backdrop/backdrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dblog.install
141 lines (132 loc) · 4 KB
/
dblog.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* @file
* Install, update and uninstall functions for the dblog module.
*/
/**
* Implements hook_schema().
*/
function dblog_schema() {
$schema['watchdog'] = array(
'description' => 'Table that contains logs of all system events.',
'fields' => array(
'wid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique watchdog event ID.',
),
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid of the user who triggered the event.',
),
'type' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'Type of log message, for example "user" or "page not found."',
),
'message' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Text of log message to be passed into the t() function.',
),
'variables' => array(
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'description' => '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' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
),
'link' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
'description' => 'Link to view the result of the event.',
),
'location' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'URL of the origin of the event.',
),
'referer' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'URL of referring page.',
),
'hostname' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Hostname of the user who triggered the event.',
),
'timestamp' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Unix timestamp of when event occurred.',
),
),
'primary key' => array('wid'),
'indexes' => array(
'type' => array('type'),
'uid' => array('uid'),
'severity' => array('severity'),
),
);
return $schema;
}
/**
* Account for possible legacy systems where dblog was not installed.
*/
function dblog_update_1000() {
if (!db_table_exists('watchdog')) {
db_create_table('watchdog', backdrop_get_schema_unprocessed('dblog', 'watchdog'));
}
}
/**
* Set the format for dates in the database log.
*/
function dblog_update_1001() {
$short = system_date_format_load('short');
config_set('system.core', 'log_date_format', $short['pattern']);
}
/**
* Convert the format for dates in the database log.
*/
function dblog_update_1002() {
// Removed. See https://github.com/backdrop/backdrop-issues/issues/4614
}
/**
* Restore the format for dates in the database log.
*/
function dblog_update_1003() {
// The "log_date_format" value may be a pattern or a named format.
$core_config = config('system.core');
$log_format = $core_config->get('log_date_format');
$date_format_config = config('system.date');
$date_formats = $date_format_config->get('formats');
// If a named pattern is in use, store its pattern directly.
if (isset($date_formats[$log_format])) {
$core_config->set('log_date_format', $date_formats[$log_format]['pattern']);
$core_config->save();
}
// Remove the previously created named format for logging.
if (isset($date_formats['dblog_date_format'])) {
unset($date_formats['dblog_date_format']);
$date_format_config->set('formats', $date_formats);
$date_format_config->save();
}
}