source: sipes/cord/modules/dblog/dblog.module @ 8a8efa8

stableversion-3.0
Last change on this file since 8a8efa8 was d7a822e, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio del cord

  • Propiedad mode establecida a 100755
File size: 5.5 KB
Línea 
1<?php
2
3/**
4 * @file
5 * System monitoring and logging for administrators.
6 *
7 * The dblog module monitors your site and keeps a list of
8 * recorded events containing usage and performance data, errors,
9 * warnings, and similar operational information.
10 *
11 * @see watchdog()
12 */
13
14/**
15 * Implementation of hook_help().
16 */
17function dblog_help($path, $arg) {
18  switch ($path) {
19    case 'admin/help#dblog':
20      $output = '<p>'. t('The dblog module monitors your system, capturing system events in a log to be reviewed by an authorized individual at a later time. This is useful for site administrators who want a quick overview of activities on their site. The logs also record the sequence of events, so it can be useful for debugging site errors.') .'</p>';
21      $output .= '<p>'. t('The dblog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the dblog report on a regular basis to ensure their site is working properly.') .'</p>';
22      $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@dblog">Dblog module</a>.', array('@dblog' => 'http://drupal.org/handbook/modules/dblog/')) .'</p>';
23      return $output;
24    case 'admin/reports/dblog':
25      return '<p>'. t('The dblog module monitors your website, capturing system events in a log to be reviewed by an authorized individual at a later time. The dblog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the dblog report on a regular basis as it is often the only way to tell what is going on.') .'</p>';
26  }
27}
28
29/**
30 * Implementation of hook_theme()
31 */
32function dblog_theme() {
33  return array(
34    'dblog_filters' => array(
35      'arguments' => array('form' => NULL),
36    ),
37  );
38}
39
40/**
41 * Implementation of hook_menu().
42 */
43function dblog_menu() {
44  $items['admin/settings/logging/dblog'] = array(
45    'title' => 'Database logging',
46    'description' => 'Settings for logging to the Drupal database logs. This is the most common method for small to medium sites on shared hosting. The logs are viewable from the admin pages.',
47    'page callback' => 'drupal_get_form',
48    'page arguments' => array('dblog_admin_settings'),
49    'access arguments' => array('administer site configuration'),
50    'file' => 'dblog.admin.inc',
51  );
52
53  $items['admin/reports/dblog'] = array(
54    'title' => 'Recent log entries',
55    'description' => 'View events that have recently been logged.',
56    'page callback' => 'dblog_overview',
57    'access arguments' => array('access site reports'),
58    'weight' => -1,
59    'file' => 'dblog.admin.inc',
60  );
61  $items['admin/reports/page-not-found'] = array(
62    'title' => "Top 'page not found' errors",
63    'description' => "View 'page not found' errors (404s).",
64    'page callback' => 'dblog_top',
65    'page arguments' => array('page not found'),
66    'access arguments' => array('access site reports'),
67    'file' => 'dblog.admin.inc',
68  );
69  $items['admin/reports/access-denied'] = array(
70    'title' => "Top 'access denied' errors",
71    'description' => "View 'access denied' errors (403s).",
72    'page callback' => 'dblog_top',
73    'page arguments' => array('access denied'),
74    'access arguments' => array('access site reports'),
75    'file' => 'dblog.admin.inc',
76  );
77  $items['admin/reports/event/%'] = array(
78    'title' => 'Details',
79    'page callback' => 'dblog_event',
80    'page arguments' => array(3),
81    'access arguments' => array('access site reports'),
82    'type' => MENU_CALLBACK,
83    'file' => 'dblog.admin.inc',
84  );
85  return $items;
86}
87
88function dblog_init() {
89  if (arg(0) == 'admin' && arg(1) == 'reports') {
90    // Add the CSS for this module
91    drupal_add_css(drupal_get_path('module', 'dblog') .'/dblog.css', 'module', 'all', FALSE);
92  }
93}
94
95
96
97/**
98 * Implementation of hook_cron().
99 *
100 * Remove expired log messages.
101 */
102function dblog_cron() {
103  // Cleanup the watchdog table
104  $max = db_result(db_query('SELECT MAX(wid) FROM {watchdog}'));
105  db_query('DELETE FROM {watchdog} WHERE wid <= %d', $max - variable_get('dblog_row_limit', 1000));
106}
107
108/**
109 * Implementation of hook_user().
110 */
111function dblog_user($op, &$edit, &$user) {
112  if ($op == 'delete') {
113    db_query('UPDATE {watchdog} SET uid = 0 WHERE uid = %d', $user->uid);
114  }
115}
116
117function _dblog_get_message_types() {
118  $types = array();
119
120  $result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type');
121  while ($object = db_fetch_object($result)) {
122    $types[] = $object->type;
123  }
124
125  return $types;
126}
127
128/**
129 * Implementation of hook_watchdog().
130 */
131function dblog_watchdog($log = array()) {
132  $current_db = db_set_active();
133  db_query("INSERT INTO {watchdog}
134    (uid, type, message, variables, severity, link, location, referer, hostname, timestamp)
135    VALUES
136    (%d, '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', %d)",
137    $log['user']->uid,
138    $log['type'],
139    $log['message'],
140    serialize($log['variables']),
141    $log['severity'],
142    $log['link'],
143    $log['request_uri'],
144    $log['referer'],
145    $log['ip'],
146    $log['timestamp']);
147
148  if ($current_db) {
149    db_set_active($current_db);
150  }
151}
152
153/**
154 * Theme dblog administration filter selector.
155 *
156 * @ingroup themeable
157 */
158function theme_dblog_filters($form) {
159  $output = '';
160  foreach (element_children($form['status']) as $key) {
161    $output .= drupal_render($form['status'][$key]);
162  }
163  $output .= '<div id="dblog-admin-buttons">'. drupal_render($form['buttons']) .'</div>';
164  return $output;
165}
166
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.