Welcome to FrostSW!

FrostMVC PHP Framework

Documentation   |   Version

Logs

FrostMVC\Logs

use FrostMVC\Logs;

Simple file-based logging utility.

Log files are written to the directory configured via setDirectory(); if none is set, the directory of the PHP error_log INI path is used. File names are based on the given name plus a '.log' extension; when no name is specified, today's date in 'Y_m_d' format is used.

Methods

::getDirectory()

Returns the configured log directory, or false when no directory has been set.

::read()

Reads the full contents of a log file as a string. When no filename is given, reads today's date log. Returns an empty string when the file does not exist.

::setDirectory()

Sets the directory where log files are written. Pass a full path without a trailing separator.

::write()

Appends a timestamped message to a log file. When only one argument is given, the message is logged to today's date file.

getDirectory() static

Logs::getDirectory()

Returns the configured log directory, or false when no directory has been set.

Returns

string|false

read() static

Logs::read($file = false)

Reads the full contents of a log file as a string. When no filename is given, reads today's date log. Returns an empty string when the file does not exist.

Parameters

$file string|false

The log filename (without '.log'), or false for today's log.

Default: false

Returns

string

setDirectory() static

Logs::setDirectory($directory)

Sets the directory where log files are written. Pass a full path without a trailing separator.

Parameters

$directory string

write() static

Logs::write($file, $value = false)

Appends a timestamped message to a log file. When only one argument is given, the message is logged to today's date file.

Parameters

$file string

The log filename (without '.log') or the message when used as the sole argument.

$value string|false

The message, or false to treat $file as the message.

Default: false

Generated from core/classes/Logs.php (FrostMVC ).