99)) - display last 99 events from all device * print_events(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 events from page 3 with pagination header * print_events(array('pagesize' => 10, 'device' = 4)) - display last 10 events for device_id 4 * print_events(array('short' => TRUE)) - show small block with last events * * @param array $vars * * @return null * */ function print_events($vars) { global $config; // Get events array $events = get_events_array($vars); if (!$events['count']) { // There have been no entries returned. Print the warning. print_warning('
' . PHP_EOL; $string .= ' | Date | ' . PHP_EOL; if ($list['device']) { $string .= 'Device | ' . PHP_EOL; } if ($list['entity']) { $string .= 'Entity | ' . PHP_EOL; } $string .= 'Message | ' . PHP_EOL; $string .= '|||
---|---|---|---|---|---|---|---|
' . PHP_EOL; if ($events['short']) { $string .= ' | '; $string .= generate_tooltip_time($entry['timestamp']) . ' | ' . PHP_EOL; } else { $string .= ''; $string .= format_timestamp($entry['timestamp']) . ' | ' . PHP_EOL; } if ($entry['device_id'] == 0 && safe_empty($entry['entity_type'])) { // Compatibility for global events $entry['entity_type'] = 'global'; } if ($list['device']) { if (in_array($entry['entity_type'], ['global', 'info'])) { // Global, Info events $string .= '' . strtoupper($entry['entity_type']) . ' | ' . PHP_EOL; } else { $dev = device_by_id_cache($entry['device_id']); $device_vars = ['page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog']; $string .= '' . generate_device_link_short($dev, $device_vars) . ' | ' . PHP_EOL; } } if ($list['entity']) { if ($entry['entity_type'] === 'device' && !$entry['entity_id']) { $entry['entity_id'] = $entry['device_id']; } if ($entry['entity_type'] === 'port') { $this_if = get_port_by_id_cache($entry['entity_id']); $entry['link'] = '' . get_icon('port') . ' ' . generate_port_link_short($this_if) . ''; } elseif ($entry['entity_type'] === 'global') { $entry['link'] = get_icon('info'); } elseif ($entry['entity_type'] === 'info') { $entry['link'] = get_icon('important'); } else { if (!empty($config['entities'][$entry['entity_type']]['icon'])) { $entry['link'] = ' ' . generate_entity_link($entry['entity_type'], $entry['entity_id']) . ''; } else { $entry['link'] = nicecase($entry['entity_type']); } } if (!$events['short']) { $string .= '' . $entry['link'] . ' | ' . PHP_EOL; } } if ($events['short']) { $string .= ''; if (strpos($entry['message'], $entry['link']) !== 0) { $string .= $entry['link'] . ' '; } } else { $string .= ' | '; } // Use markdown parsed for Debug events, for allow links to docs (use Markdown Extra). $message_escape = $entry['severity'] >= 7 ? get_markdown_extra($entry['message']) : escape_html($entry['message']); $string .= $message_escape . ' | ' . PHP_EOL; //$string .= $entry['message'] . '' . PHP_EOL; $string .= '