# Logging

Wolff\Core\Log

You can know what's happening in your Wolff project using the Logging class.

The methods of the Logging class can be called anywhere inside your Wolff project.

Files

The logging files are located by default in the system/logs folder.

Every logging file represents a day and contains logs with the format [date][ip] [level]: [message].

Logging

These are the available logging methods:

$log->emergency($msg, $values = []);
$log->alert($msg, $values = []);
$log->critial($msg, $values = []);
$log->error($msg, $values = []);
$log->warning($msg, $values = []);
$log->notice($msg, $values = []);
$log->info($msg, $values = []);
$log->debug($msg, $values = []);

The same example showed below can be applied to the other methods.

$log = new Log();
$log->info('Welcome to Wolff.');

That will log the message 'Welcome to Wolff' as an info.

Interpolation

The methods to logging data can take an optional second parameter which is an associative array with values to interpolate in the string.

The values to interpolate must be between curly brackets like {this}.

$log->debug('The user is {name} in the page {page}', [
    'name' => 'Thomas',
    'page' => 'home/',
]);

As an example, that should log The user is Thomas in the page home/.

General methods

Is enabled

isEnabled()

Returns true if the log system is enabled, false otherwise.

$log->isEnabled();

If the log system is disabled, nothing will happen when running the common log methods explained above.

Set status

setStatus([bool $enabled])

Sets the status of the logging system. true to enable it, false to disable it.

$log->setStatus(true);

Set folder

setFolder([string $folder])

Sets the folder where the log files will be stored.

$log->setFolder('app/logs');

The given path is relative to the project root folder.

Set date format

setDateFormat([string $format])

Sets the date format used internally in the log files.

The PHP date function is used internally with the given date format. You can read the function's documentation for better understanding of the string you pass.

$log->setDateFormat('H:i:s');

That will set the format like this: Hour:minutes:seconds.

Documentation made with
Something is wrong in here? Make a issue/pull request on the repo.