<?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->session->set('username','Raja');
echo $this->session->get('username');
$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 */
PD9waHAgIGlmICggISBkZWZpbmVkKCdCQVNFUEFUSCcpKSBleGl0KCdObyBkaXJlY3Qgc2NyaXB0IGFjY2VzcyBhbGxvd2VkJyk7Ci8qKgogKiBDb2RlSWduaXRlcgogKgogKiBBbiBvcGVuIHNvdXJjZSBhcHBsaWNhdGlvbiBkZXZlbG9wbWVudCBmcmFtZXdvcmsgZm9yIFBIUCA1LjEuNiBvciBuZXdlcgogKgogKiBAcGFja2FnZQkJQ29kZUlnbml0ZXIKICogQGF1dGhvcgkJRXhwcmVzc2lvbkVuZ2luZSBEZXYgVGVhbQogKiBAY29weXJpZ2h0CUNvcHlyaWdodCAoYykgMjAwOCAtIDIwMTEsIEVsbGlzTGFiLCBJbmMuCiAqIEBsaWNlbnNlCQlodHRwOi8vYy4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uci5jb20vdXNlcl9ndWlkZS9saWNlbnNlLmh0bWwKICogQGxpbmsJCWh0dHA6Ly9jLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5yLmNvbQogKiBAc2luY2UJCVZlcnNpb24gMS4wCiAqIEBmaWxlc291cmNlCiAqLwoKLy8gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgovKioKICogTG9nZ2luZyBDbGFzcwogKgogKiBAcGFja2FnZQkJQ29kZUlnbml0ZXIKICogQHN1YnBhY2thZ2UJTGlicmFyaWVzCiAqIEBjYXRlZ29yeQlMb2dnaW5nCiAqIEBhdXRob3IJCUV4cHJlc3Npb25FbmdpbmUgRGV2IFRlYW0KICogQGxpbmsJCWh0dHA6Ly9jLi4uY29udGVudC1hdmFpbGF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