Documentation

phplog
in package

Class phplog

Tags
author

Lutz Boldt boldt@bitstore-online.de

Table of Contents

Properties

$logFile  : string

Methods

all()  : array<string|int, mixed>|false
Returns all log entries stored in the log file.
clear()  : bool
count()  : string
parselines()  : array<string|int, mixed>|false
Parses an array of lines and returns the trimmed lines separated between "#####################" delimiters.
trimfirstsixrows()  : array<string|int, mixed>
Trims the first six rows in an array of lines from a log file and returns an associative array containing the extracted values for timestamp, IP address, file, row, error level, and message.
trimlines()  : array<string|int, mixed>
Trims the lines in an array of file content and separates the trimmed lines between "#####################" delimiters

Properties

$logFile

protected string $logFile = path . '/logs/main/phperror.log'

Methods

all()

Returns all log entries stored in the log file.

public all() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

Returns an array of log entries if any exist, otherwise returns false.

clear()

public clear() : bool
Return values
bool

count()

public count() : string
Return values
string

parselines()

Parses an array of lines and returns the trimmed lines separated between "#####################" delimiters.

private parselines(array<string|int, mixed> $line) : array<string|int, mixed>|false

If the number of lines is equal to 6, it calls the trimfirstsixrows() method to trim the first six rows. If the number of lines is greater than 6, it calls the trimfirstsixrows() method to trim the first six rows, and if the seventh line is "Stack trace:", it appends the remaining lines as a single string to the 'stacktrace' key in the result. If the array of lines is empty, it returns false.

Parameters
$line : array<string|int, mixed>

The array of lines to parse

Return values
array<string|int, mixed>|false

The trimmed lines separated between "#####################" delimiters, or false if the array of lines is empty

trimfirstsixrows()

Trims the first six rows in an array of lines from a log file and returns an associative array containing the extracted values for timestamp, IP address, file, row, error level, and message.

private trimfirstsixrows(array<string|int, mixed> $line) : array<string|int, mixed>
Parameters
$line : array<string|int, mixed>
Return values
array<string|int, mixed>

An associative array containing the extracted values

  • 'stamp' : The timestamp as a UNIX timestamp
  • 'ip' : The IP address
  • 'file' : The file name
  • 'row' : The row number
  • 'errlvl' : The error level
  • 'message' : The log message

trimlines()

Trims the lines in an array of file content and separates the trimmed lines between "#####################" delimiters

private trimlines(array<string|int, mixed> $filecontent) : array<string|int, mixed>
Parameters
$filecontent : array<string|int, mixed>

The array of file content to trim

Return values
array<string|int, mixed>

The trimmed lines separated between "#####################" delimiters


        
On this page

Search results