Documentation

CFileLogger
in package
implements ILogger

A concrete logger implementation that writes directly to a file.

This class implements the ILogger interface and handles logging without any external dependencies like Monolog.

Table of Contents

Interfaces

ILogger
Interface for logging operations, compliant with PSR-3 log levels.

Properties

$LogLevels  : mixed
$log_level  : mixed
$log_file_path  : string

Methods

__construct()  : mixed
Constructor for CFileLogger.
AddLog()  : void
Logs a request and its corresponding response with a custom format.
Alert()  : void
Action must be taken immediately.
Critical()  : void
Critical conditions.
Debug()  : void
Detailed debug information.
Emergency()  : void
System is unusable.
Error()  : void
Runtime errors that do not require immediate action but should typically be logged and monitored.
Info()  : void
Interesting events.
Notice()  : void
Normal but significant events.
Warning()  : void
Exceptional occurrences that are not errors.
Log()  : void
Generic log method to format and write standard log messages.
Write()  : void
Writes a formatted string to the log file.

Properties

$LogLevels

public mixed $LogLevels = ["EMERGENCY" => 0, "ALERT" => 1, "CRITICAL" => 2, "ERROR" => 3, "WARNING" => 4, "NOTICE" => 5, "INFO" => 6, "DEBUG" => 7]

$log_file_path

private string $log_file_path

The full path to the log file

Methods

__construct()

Constructor for CFileLogger.

public __construct([string $log_file_path = LOGS_PATH . 'application.log' ][, int $log_level = 4 ]) : mixed
Parameters
$log_file_path : string = LOGS_PATH . 'application.log'

The full path to the log file.

$log_level : int = 4
Tags
throws
Exception

if the log directory is not writable.

AddLog()

Logs a request and its corresponding response with a custom format.

public AddLog(CUser $user, CRequest|null $request, CResponse|null $response) : void
Parameters
$user : CUser

The user object associated with the request.

$request : CRequest|null

The request object containing input data.

$response : CResponse|null

The response object containing output data.

Alert()

Action must be taken immediately.

public Alert(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Critical()

Critical conditions.

public Critical(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Debug()

Detailed debug information.

public Debug(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Emergency()

System is unusable.

public Emergency(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Error()

Runtime errors that do not require immediate action but should typically be logged and monitored.

public Error(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Info()

Interesting events.

public Info(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Notice()

Normal but significant events.

public Notice(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Warning()

Exceptional occurrences that are not errors.

public Warning(string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$message : string

The log message.

$context : array<string|int, mixed> = []

The log context.

Log()

Generic log method to format and write standard log messages.

private Log(string $level, string $message, array<string|int, mixed> $context[, mixed $back_trace = 1 ]) : void
Parameters
$level : string

The log level.

$message : string

The log message.

$context : array<string|int, mixed>

The context data.

$back_trace : mixed = 1

Write()

Writes a formatted string to the log file.

private Write(string $log_entry) : void
Parameters
$log_entry : string

The complete string to write.


        
On this page

Search results