<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://c...content-available-to-author-only...r.com/user_guide/license.html
* @link http://c...content-available-to-author-only...r.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* Logging Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Logging
* @author ExpressionEngine Dev Team
* @link http://c...content-available-to-author-only...r.com/user_guide/general/errors.html
*/
class CI_Log {
protected $_log_path;
protected $_threshold = 1;
protected $_date_fmt = 'Y-m-d H:i:s';
protected $_enabled = TRUE;
protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
/**
* Constructor
*/
public function __construct()
{
$config =& get_config();
$this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/';
if ( ! is_dir($this->_log_path
) OR
! is_really_writable
($this->_log_path
)) {
$this->_enabled = FALSE;
}
{
$this->_threshold = $config['log_threshold'];
}
if ($config['log_date_format'] != '')
{
$this->_date_fmt = $config['log_date_format'];
}
}
// --------------------------------------------------------------------
/**
* Write Log File
*
* Generally this function will be called using the global log_message() function
*
* @param string the error level
* @param string the error message
* @param bool whether the error is a native PHP error
* @return bool
*/
public function write_log($level = 'error', $msg, $php_error = FALSE)
{
if ($this->_enabled === FALSE)
{
return FALSE;
}
if ( ! isset($this->_levels
[$level]) OR
($this->_levels
[$level] > $this->_threshold
)) {
return FALSE;
}
$filepath = $this->_log_path
.'log-'.date('Y-m-d').'.php'; $message = '';
{
$message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
}
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE
)) {
return FALSE;
}
$message .= $level.' '.(($level == 'INFO') ?
' -' : '-').' '.date($this->_date_fmt
). ' --> '.$msg."\n";
@chmod($filepath, FILE_WRITE_MODE
); return TRUE;
}
}
// END Log Class
/* End of file Log.php */
/* Location: ./system/libraries/Log.php */
PD9waHAgIGlmICggISBkZWZpbmVkKCdCQVNFUEFUSCcpKSBleGl0KCdObyBkaXJlY3Qgc2NyaXB0IGFjY2VzcyBhbGxvd2VkJyk7Ci8qKgogKiBDb2RlSWduaXRlcgogKgogKiBBbiBvcGVuIHNvdXJjZSBhcHBsaWNhdGlvbiBkZXZlbG9wbWVudCBmcmFtZXdvcmsgZm9yIFBIUCA1LjEuNiBvciBuZXdlcgogKgogKiBAcGFja2FnZQkJQ29kZUlnbml0ZXIKICogQGF1dGhvcgkJRXhwcmVzc2lvbkVuZ2luZSBEZXYgVGVhbQogKiBAY29weXJpZ2h0CUNvcHlyaWdodCAoYykgMjAwOCAtIDIwMTEsIEVsbGlzTGFiLCBJbmMuCiAqIEBsaWNlbnNlCQlodHRwOi8vYy4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uci5jb20vdXNlcl9ndWlkZS9saWNlbnNlLmh0bWwKICogQGxpbmsJCWh0dHA6Ly9jLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5yLmNvbQogKiBAc2luY2UJCVZlcnNpb24gMS4wCiAqIEBmaWxlc291cmNlCiAqLwoKLy8gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgovKioKICogTG9nZ2luZyBDbGFzcwogKgogKiBAcGFja2FnZQkJQ29kZUlnbml0ZXIKICogQHN1YnBhY2thZ2UJTGlicmFyaWVzCiAqIEBjYXRlZ29yeQlMb2dnaW5nCiAqIEBhdXRob3IJCUV4cHJlc3Npb25FbmdpbmUgRGV2IFRlYW0KICogQGxpbmsJCWh0dHA6Ly9jLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi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