info($msg, $method = null)
The info method allows you to write a log entry with the $level "Info".
Static | Yes | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
|||||||||
Returns | boolean | |||||||||
Example |
|
The log class allows you to write messages to the log files.
The log files are being placed in the folder specified by the attribute 'log_path' in the config.php. You can also set the 'log_threshold' and the 'log_date_format' parameters there.
These settings can also be changed on the fly by using the Config Class.
Param | Type | Default | Description |
---|---|---|---|
log_threshold | constant |
|
Can be any of the following: Fuel::L_NONE, Fuel::L_ERROR, Fuel::L_DEBUG, Fuel::L_INFO or Fuel::L_ALL
|
log_path | string |
|
Where to put the log files. (Folder must be writable) |
log_date_format | string |
|
The date format for the log entries. This format must follow the PHP date format rules. See http://www.php.net/date for a complete list. |
There are three predefined functions for ease of use:
Log::info()
Log::debug()
Log::error()
They all use the main function Log::write() which requires the $level parameter as the first argument.
// Write a log entry with the level "Info" to the log file for the current day
$var = 1;
Log::info('Application started (with $var = '.$var.')', 'my_init_function()');
// Save the new value of $var to the log file, without the $method parameter
$var = 5;
Log::debug('$var is now '.$var);
// Send an error log entry
if($var !== 1) Log::error('We cannot keep going, $var has been changed! :o');
// Finally, create a log entry with a custom $level
Log::write('Link', 'More info on http://fuelphp.com/');
All log files are being placed in the defined folder (see above), composed in folders named by the current year followed by the month ("2011/06" for example) with the day of the month as the filename ("15.php" for example).
The complete path to our example log file would be: APPPATH.'logs/2011/06/15.php'
The examples above would write the following code to the log file:
<?php defined('COREPATH') or exit('No direct script access allowed'); ?>
Info - 2011-01-03 18:44:45 --> my_init_function() - Application started (with $var = 1)
Debug - 2011-01-03 18:44:45 --> $var is now 5
Error - 2011-01-03 18:44:45 --> We cannot keep going, $var has been changed! :o
Link - 2011-01-03 18:44:45 --> More info on http://fuelphp.com/
The info method allows you to write a log entry with the $level "Info".
Static | Yes | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
|||||||||
Returns | boolean | |||||||||
Example |
|
The debug method allows you to write a log entry with the $level "Debug".
Static | Yes | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
|||||||||
Returns | boolean | |||||||||
Example |
|
The error method allows you to write a log entry with the $level "Error".
Static | Yes | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
|||||||||
Returns | boolean | |||||||||
Example |
|
The write method allows you to write a log entry with a custom $level.
Static | Yes | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Returns | boolean | ||||||||||||
Example |
|