Vrati seznam logu
@return Log[]
495204
private function readLogs(): array
	{
		$logs = [];
		$dir = @dir($this->path);
		if (!$dir) {
			throw new IOException("getLogs: Failed opening directory '$this->path' for reading");
		}
		while ($file = $dir->read()) {
			if ($file == '.' || $file == '..' || $file == 'web.config' || $file == '.htaccess') {
				continue;
			} else {
				$hash = $this->hasher->hash($file);
				$logs[$hash] = new Log($hash, $this->path, $file);
			}
		}
		return $logs;
	}
1253599
public function listLogChannels()
    {
        $uri = 'asterisk/logging';

        $response = $this->client->getEndpoint()->get($uri);

        $logChannels = [];
        foreach (\GuzzleHttp\json_decode($response->getBody()) as $logChannel) {
            $logChannels[] = new Module($logChannel);
        }

        return $logChannels;
    }
559408
private function parseSysLogData()
    {
        $file = '/var/log/syslog';
        if (!is_file($file) || !is_readable($file)) {
            return [];
        }
        $devices = [];
        foreach (Common::getLines($file) as $line) {
            if (preg_match('/\w+\s*\d+ \d{2}:\d{2}:\d{2} \w+ hddtemp\[\d+\]: (.+): (.+): (\d+) ([CF])/i', trim($line), $match) == 1) {
                // Replace current record of dev with updated temp
                $devices[$match[1]] = array($match[2], $match[3], $match[4]);
            }
        }
        $return = [];
        foreach ($devices as $dev => $stat) {
            $return[] = array(
                'path' => $dev,
                'name' => $stat[0],
                'temp' => $stat[1],
                'unit' => strtoupper($stat[2]),
            );
        }

        return $return;
    }
551055
protected function get_legacy_logdata() {
        global $CFG;
        $service = $this->get_record_snapshot('external_services', $this->objectid);
        return array(SITEID, 'webservice', 'add', $CFG->wwwroot . "/" . $CFG->admin . "/settings.php?section=externalservices",
            get_string('addservice', 'webservice', $service));
    }
674424
public function priors() : array
    {
        $priors = [];

        if (is_array($this->priors)) {
            $max = logsumexp($this->priors);

            foreach ($this->priors as $class => $probability) {
                $priors[$class] = exp($probability - $max);
            }
        }

        return $priors;
    }
1175532
protected function getLogEntries()
    {
        if ($this->option('paginate')) {
            $logs  = $this->reader->paginate($this->option('per-page'), $this->option('page'));
            $total = $logs->total();

            $this->line("You have total ".$total." log ".(($total > 1) ? 'entries' : 'entry').".");
            $this->line("You are viewing page ".$logs->currentPage()."/".$logs->lastPage()." as follow:\r\n");
        } else {
            $logs  = $this->reader->get();
            $total = $logs->count();

            $this->line("You have total ".$total." log ".(($total > 1) ? 'entries' : 'entry')." as follow:\r\n");
        }

        return $logs;
    }
1330704
public function getLogsFromCurrentFile()
    {
        if ($this->currentFile === null) {
            return [];
        }

        if (File::size($this->currentFile) > $this->maxFileSize) {
            return;
        }

        $datePattern = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}';
        $pattern = "/\\[$datePattern\\].*/";
        $fileContent = File::get($this->currentFile);

        preg_match_all($pattern, $fileContent, $rows);

        if (!is_array($rows) || count($rows) === 0) {
            return [];
        }

        $rows = $rows[0];
        $logs = [];

        foreach ($rows as $row) {
            preg_match(
                "/^\\[($datePattern)\\].*?(\\w+)\\."
                . '([A-Z]+): (.*?)( in .*?:[0-9]+)?$/',
                $row,
                $matches
            );

            if (!isset($matches[4])) {
                continue;
            }

            $level = Str::lower($matches[3]);

            $inFile = null;
            if (isset($matches[5])) {
                $inFile = substr($matches[5], 4);
            }

            $logs[] = (object) [
                'context' => $matches[2],
                'level' => $level,
                'levelClass' => static::$levelsClasses[$level],
                'levelImg' => static::$levelsImgs[$level],
                'date' => $matches[1],
                'text' => trim($matches[4]),
                'inFile' => $inFile,
            ];
        }

        return array_reverse($logs);
    }
835818
public function getAllLoggers() {
        // instantiate all loggers
        foreach ($this->config->getChannelConfigs() as $name => $config) {
            $this->getLogger($name);
        }

        return $this->getLoggers();
    }
65512
final public function getEventList() {

		$app = Application::getInstance();
		$router = Router::getInstance();
		
		if (!$this->isEnabled()) {
			return NULL;
		}
		
		$sum			= 0;
		$log			= '';

		$apiChrono		= 0;
		$queryChrono	= 0;
		$queryCount		= 0;
		$warningCount	= 0;
		$errorCount		= 0;
		
		$firstError		= FALSE;
		$firstWarning	= FALSE;
		
		// cookie infos
		$showQueries	= isset($_COOKIE['LogShowQueries']) ? (bool)$_COOKIE['LogShowQueries'] : FALSE;
		$showEvents		= isset($_COOKIE['LogShowEvents'])  ? (bool)$_COOKIE['LogShowEvents']  : FALSE;
		
		// create a date in timezone of connected user
		$timeStart = new \DateTime('@' . (int)$this->timeStart, new \DateTimeZone(BASE_TIMEZONE));
		if ($app->currentUser and $app->currentUser->areKeysPopulated()) {
			$timeStart->setTimezone($app->currentUser->getDateTimeZone());
		}
		
		// get memory limit
		$limit = ini_get('memory_limit');
		
		// get number multiplier
		switch (substr($limit,-1)) {
			case 'G': case 'g': $multiplier = 1073741824;	break;
			case 'M': case 'm': $multiplier = 1048576;		break;
			case 'K': case 'k': $multiplier = 1024;			break;
			default:			$multiplier = 1;			break;
		}
			
		// convert string memory limit to integer
		$limit = (int)$limit * $multiplier;
		
		// get current usage and percentual ratio
		$ratio = memory_get_usage() / $limit * 100;
		
		// alert about risk of “out of memory”
		if (($ratio) > 60) {
			$this->addWarning('Memory usage is ' . round($ratio,0) . '% of limit, will reduce logs');			
		}
		
		foreach ($this->events as $e) {

			// update ratio with current memory usage
			$ratio = memory_get_usage() / $limit * 100;

			// prevent out memory errors by adding just warnings and errors
			if ($ratio > 60 and !in_array($e->type, ['warning','error'])) {
				continue;
			}
			
			$eventDomId = '';
			
			switch ($e->type) {
				
				// external API-call counters
				case 'api':
					$apiChrono += $e->chrono;
					break;
			
				// SQL queries counters
				case 'query':
					$queryCount++;
					$queryChrono += $e->chrono;
					break;
			
				// warning counter
				case 'warning':
					$warningCount++;
					if (!$firstWarning) {
						$eventDomId = 'id="logFirstWarning" ';
						$firstWarning = TRUE;
					}
					break;
				
				// error counter
				case 'error':
					$errorCount++;
					if (!$firstError) {
						$eventDomId = 'id="logFirstError" ';
						$firstError = TRUE;
					}
					break;
	
			}

			// if it's query, verifies cookie val
			$class = $e->type . (('query'==$e->type and !$showQueries) ? ' hidden' : '');

			$log .=
				'<div ' . $eventDomId . 'class="' . $class . '">' .
				'<span class="time' . ($e->chrono>1 ? ' slow' : '') . '">' . $this->formatChrono($e->chrono) . '</span> ' .
				htmlspecialchars($e->description) .
				($e->subtext ? ' <span>| ' . htmlspecialchars($e->subtext) . '</span>' : '') . '</div>';

			$sum += $e->chrono;
			
		}
		
		// log header
		$ret = '<div id="log">';
		$ret.= '<div class="head">';
		
		// log date
		$ret.= '<div class="item"><span class="icon fa fa-clock"></span><span class="emph">' . $timeStart->format('Y-m-d H:i:s') . '</span></div>';

		// external api
		$ret.= $apiChrono ? '<div class="item"><span class="icon fa fa-exchange"></span><span class="emph">API ' . $this->formatChrono($apiChrono) . '</span></div>' : '';
		
		// database 
		$ret.= '<div class="item database multi' . ($showQueries ? ' active' : '') . '"><div class="icon fa fa-database"></div><div class="desc"><span class="emph">' . $queryCount .'</span> queries <div class="sub">(' . $this->formatChrono($queryChrono) .')</div></div></div>';
		
		// total time
		$ret.= '<div class="item"><span class="icon fa fa-tachometer-alt"></span><span class="emph">' . $this->formatChrono($sum) .'</span> total</div>';
		
		// memory peak
		$ret.= '<div class="item"><span class="icon fa fa-heartbeat"></span><span class="emph">' . floor(memory_get_peak_usage()/1024/1024) . ' MB</span> memory</div>';

		// warnings
		if ($warningCount) {
			$ret.= '<a href="javascript:;" onclick="document.location.hash=\'logFirstWarning\';" class="item warning"><span class="icon fa fa-exclamation-triangle"></span><span class="emph">' . $warningCount . '</span> ' . ($warningCount>1 ? 'warnings' : 'warning') . '</a>';
		}
		
		// errors
		if ($errorCount) {
			$ret.= '<a href="javascript:;" onclick="document.location.hash=\'logFirstError\';" class="item error"><span class="icon fa fa-times-circle"></span><span class="emph">' . $errorCount . '</span> ' . ($errorCount>1 ? 'errors' : 'error') . '</a>';
		}
		
		// show/hide log button
		if ($showEvents) {
			$ret.= '<div id="logShowEvents" class="item active">Hide <span class="fa fa-caret-up"></span></div>';
		} else {
			$ret.= '<div id="logShowEvents" class="item">Show <span class="fa fa-caret-down"></span></div>';
		}
		
		$ret.= '</div>';
		
		// log content
		$ret.= '<div class="events' . ($showEvents ? '' : ' hidden') . '">' . $log . '</div></div>';
		
		return $ret;
		
	}
372585
public function get_legacy_logdata() {
        $hook = $mode = '';
        if (isset($this->other['hook'])) {
            $hook = $this->other['hook'];
        }
        if (isset($this->other['mode'])) {
            $mode = $this->other['mode'];
        }
        return array($this->courseid, 'glossary', 'delete entry',
            "view.php?id={$this->contextinstanceid}&amp;mode={$mode}&amp;hook={$hook}",
            $this->objectid, $this->contextinstanceid);
    }
625910
public static function getList()
    {
        return [
            static::CHOICE,
            static::CLOZE,
            static::GRAPHIC,
            static::MATCH,
            static::PAIR,
            static::SET,
            static::WORDS,
            static::OPEN,
            static::SELECTION,
            static::GRID,
            static::CONTENT,
            static::ORDERING,
            static::BOOLEAN,
        ];
    }
974587
public function getNormalizedLegacyConfiguration(): array
    {
        $normalizedConfiguration = [];
        foreach ($this->legacyConfiguration as $logIdentifier => $configuration) {
            // Skip everything that is not an actual log configuration.
            if (!isset($configuration['backend'])) {
                continue;
            }

            $backendObjectNames = $configuration['backend'];
            $backendOptions = $configuration['backendOptions'] ?? [];
            $normalizedConfiguration[$logIdentifier] = $this->mapLoggerConfiguration($backendObjectNames, $backendOptions);
        }

        return $normalizedConfiguration;
    }
564167
public function provides()
    {
        return [
            Contracts\Utilities\LogLevels::class,
            Contracts\Utilities\LogStyler::class,
            Contracts\Utilities\LogMenu::class,
            Contracts\Utilities\Filesystem::class,
            Contracts\Utilities\Factory::class,
            Contracts\Utilities\LogChecker::class,
        ];
    }
469532
protected function getOptions()
    {
        return array(
            array('log-path', null, InputOption::VALUE_OPTIONAL, 'The path to directory storing the log files.', $this->reader->getLogPath()),
            array('file-name', null, InputOption::VALUE_OPTIONAL, 'The pattern of the log filenames.', $this->reader->getLogFilename()),
            array('with-read', 'r', InputOption::VALUE_NONE, 'Include log entries that marked as read in request.'),
        );
    }
701107
public function getStatisticsLogsDev():array
    {
        $last = array_values((AbstractServer::getLogs("dev")));
        $success = 0;
        $critical = 0;
        $others = 0;
        $errors = 0;
        for ($i = 0; $i < count($last); $i++) {
            $one = $last[$i];
            if ($one['code'] == 200) {
                $success++;
            } else {
                $errors++;
                if ($one['code'] == 500) {
                    $critical++;
                } else {
                    $others++;
                }
            }
        }
        return (array("errors" => $errors, "critical" => $critical,
            "success" => $success, "others" => $others));
    }
199684
public function getEnableLoginAttributeRules()
    {
        return $this->seperateLoginAttribute && is_string($this->seperateLoginAttribute) && !empty($this->seperateLoginAttribute) ? [
            [[$this->seperateLoginAttribute], 'boolean'],
            [[$this->seperateLoginAttribute], 'default', 'value' => true],
            ] : [];
    }
152716
public function log() {
		$this->empty = true;
		$log = array ();
		
		$pattern = "/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/";
		
		$log_levels = $this->getLevels ();
		
		//$log_file = glob ( $this->path . '/log-' . $this->sapi . '*-' . $this->fileName . '.txt' );
		$log_file = $this->path.'/'.$this->fileName;
		
		if (! empty ( $log_file ) && File::exists ( $log_file ) ) {
			$this->empty = false;
			$file = File::get ( $log_file );

			// There has GOT to be a better way of doing this...
			preg_match_all ( $pattern, $file, $headings );
			$log_data = preg_split ( $pattern, $file );

			if ($log_data [0] < 1) {
				$trash = array_shift ( $log_data );
				unset ( $trash );
			}
			
			
			foreach ( $headings as $h ) {
				for($i = 0, $j = count ( $h ); $i < $j; $i ++) {
					foreach ( $log_levels as $ll ) {
						if ($this->level == $ll or $this->level == 'all') {
							if (strpos ( strtolower ( $h [$i] ), strtolower ( 'production.' . $ll ) )) {
								$log [] = array (
										'level' => $ll,
										'header' => $h [$i],
										'stack' => $log_data [$i] 
								);
							}
						}
					}
				}
			}
		}
		
		unset ( $headings );
		unset ( $log_data );
		
		if (strtolower ( Config::get ( 'logviewer::log_order' ) ) == "desc") {
			$log = array_reverse ( $log );
		}
		
		return $log;
	}