You are here

filelog_ui.module in File Log 6.2

Viewer UI for file based logging.

File

filelog_ui.module
View source
<?php

/**
 * Implementation of hook_help().
 */
function filelog_ui_help($path, $arg) {
  switch ($path) {
    case 'admin/help#filelog_ui':
      $output = '<p>' . t('The file logging module monitors your system, capturing system events in log files 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>';
      $output .= '<p>' . t('Each log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the reports on a regular basis to ensure their site is working properly.') . '</p>';

      //$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>';
      return $output;
  }
}

/**
 * @file
 * Viewer UI for file based logging.
 */

/**
 * Implementation of hook_init()
 */
function filelog_ui_init() {
  if (arg(0) == 'admin' && arg(1) == 'reports' && strpos(arg(2), 'filelog') === 0) {

    // Add the CSS for this module
    drupal_add_css(drupal_get_path('module', 'filelog_ui') . '/filelog-ui.css', 'module', 'all', FALSE);
  }
}

/**
 * Implementation of hook_menu()
 */
function filelog_ui_menu() {
  $items['admin/settings/logging/filelog'] = array(
    'title' => 'File logging',
    'description' => 'Settings for logging to the File system. This is the most common method for Linux/UNIX boxes. The logs are viewable from the admin pages.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'filelog_ui_admin_settings',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'filelog_ui.admin.inc',
  );
  $items['admin/reports/filelog'] = array(
    'title' => 'Recent file log entries',
    'description' => 'View events that have recently been logged.',
    'page callback' => 'filelog_ui_overview',
    'access arguments' => array(
      'access site reports',
    ),
    'weight' => -1,
    'file' => 'filelog_ui.pages.inc',
  );
  $items['admin/reports/filelog-page-not-found'] = array(
    'title' => "Top 'page not found' errors - File logging",
    'description' => "View 'page not found' errors (404s).",
    'page callback' => 'filelog_ui_top',
    'page arguments' => array(
      'page not found',
    ),
    'access arguments' => array(
      'access site reports',
    ),
    'file' => 'filelog_ui.pages.inc',
  );
  $items['admin/reports/filelog-access-denied'] = array(
    'title' => "Top 'access denied' errors - File logging",
    'description' => "View 'access denied' errors (403s).",
    'page callback' => 'filelog_ui_top',
    'page arguments' => array(
      'access denied',
    ),
    'access arguments' => array(
      'access site reports',
    ),
    'file' => 'filelog_ui.pages.inc',
  );
  $items['admin/reports/filelog-entry/%filelog_entry'] = array(
    'title' => 'Details',
    'page callback' => 'filelog_ui_entry',
    'page arguments' => array(
      3,
    ),
    'access arguments' => array(
      'access site reports',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'filelog_ui.pages.inc',
  );
  return $items;
}

/**
 * Implementation of hook_load()
 */
function filelog_entry_load($wid) {
  return db_result(db_query("SELECT * FROM {filelog} WHERE wid = '%s'", $wid));
}

/**
 * Implementation of hook_cron().
 *
 * Remove expired log messages and import new ones.
 */
function filelog_ui_cron() {
  $time = time();

  // Cleanup the filelog table
  if ($age = variable_get('filelog_maxage', 2592000)) {
    db_query('DELETE FROM {filelog} WHERE timestamp <= %d', $time - $age);
  }
  if (($freq = variable_get('filelog_import_frequency', 604800)) && $time > variable_get('filelog_last_import', 0) + $freq) {
    module_load_include('inc', 'filelog_ui', 'filelog_ui.admin');
    filelog_ui_import_entries();
    cache_clear_all('filelog_type_registry', 'cache', FALSE);
  }
}

/**
 * Implementation of hook_user().
 */
function filelog_ui_user($op, &$edit, &$user) {
  if ($op == 'delete') {
    db_query('UPDATE {filelog} SET uid = 0 WHERE uid = %d', $user->uid);
  }
}

/**
 * Implementation of hook_theme()
 */
function filelog_ui_theme($existing, $type, $theme, $path) {
  return array(
    'filelog_ui_filters' => array(
      'arguments' => array(
        'form' => NULL,
      ),
      'file' => 'filelog_ui.pages.inc',
      'path' => $path,
    ),
  );
}

Functions

Namesort descending Description
filelog_entry_load Implementation of hook_load()
filelog_ui_cron Implementation of hook_cron().
filelog_ui_help Implementation of hook_help().
filelog_ui_init Implementation of hook_init()
filelog_ui_menu Implementation of hook_menu()
filelog_ui_theme Implementation of hook_theme()
filelog_ui_user Implementation of hook_user().