예제 #1
0
<?php

// Starts session before header is sent
session_start();
require_once '../../../init/initLog.inc.php';
$currentDay = DateTool::getTimeString(DateTool::FORMAT_MYSQL_DATE);
define('TAIL_LOG_FILE', LOG_DIR . '/' . $currentDay . '-web.log');
$grep = RequestTool::getParameter('grep', RequestTool::PARAM_TYPE_FREE, false);
$logFile = file_exists(TAIL_LOG_FILE) ? file(TAIL_LOG_FILE) : array();
$starterLine = SessionTool::getInstance()->getParameter('startLine', false, 0);
$lineCount = count($logFile);
for ($index = $starterLine; $index < $lineCount; ++$index) {
    // Filter lines per grep
    if ($grep && !StringTool::strpos($logFile[$index], $grep)) {
        continue;
    }
    $truncate = true;
    switch (StringTool::substr($logFile[$index], 0, 7)) {
        case "":
            $color = '#5F5';
            // Green
            break;
        case "":
            $color = '#FF5';
            // Yellow
            break;
        case "":
            $color = '#F55';
            // Red
            break;
        case "":
 /**
  * Checks if a string contains another one
  * @param string $string The original string
  * @param string $search The searched string
  * @return boolean If the $string contains at least one occurence of $search or not
  */
 public static function contains($string, $search)
 {
     return StringTool::strpos($string, $search) !== false;
 }