This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

Logging

Addon developers and site builders may find it useful to log messages that can later be viewed and searched in the dashboard. The concrete5 log library provides this functionality.

Loading the Library

You should not have to do anything to load the logging library.

Viewing the Logs

Logs can be viewed and searched in Dashboard > Reports > Logs.

Adding a single entry to the Log

To quickly add a single entry to the log, use the following method

	Log::addEntry('I wish to log this string.');

It will appear in the dashboard immediately.

Using Log Sessions and Typing

For more flexibility, consider typing your log entry, and/or using log sessions. Log sessions are a way for developers to add multiple lines to one log entry, over the course of several log calls in a given series. Typed logs can easily be searched and filtered in the dashboard.

The following example adds several separate calls to the same log entry, under the "special_application" log type:

	$l = new Log('special_application', true); 	$l->write('Entry 1'); 	$l->write('Entry 2'); 	$l->write('Entry 3'); 	$l->close();

Methods

__construct($type = null, $session = false, $internal = false)

Creates a new instance of the log constructor. If $log is null, no type will be used. If $session is false, the log will automatically be closed after the first entry is written. $internal denotes items that are internal concrete5 logs.

$log->write($message)

Adds a message to the current log object

$log->close()

Closes the current log object and writes all log entries in the session to the Logs table.

static Log::addEntry($string)

Quickly adds $string to the Logs table with no type.

Loading Conversation