-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMY_Log.php
More file actions
80 lines (60 loc) · 1.52 KB
/
MY_Log.php
File metadata and controls
80 lines (60 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
*
* @author dhirajwebappclouds
*
*/
class MY_Log extends CI_Log {
function __construct()
{
$config =& get_config();
parent::__construct();
}
public function write_log($level = 'error', $msg, $php_error = false) { //here overriding
if ($this->_enabled === FALSE)
{
return FALSE;
}
$level = strtoupper($level);
if ( ! isset($this->_levels[$level]) OR
($this->_levels[$level] > $this->_threshold))
{
return FALSE;
}
// if info create custom log
if($level == 'INFO'){
/* HERE YOUR LOG FILENAME YOU CAN CHANGE ITS NAME */
$filepath = $this->_log_path.'customlog-'.date('Y-m-d').'.log';
$message = '';
if ( ! file_exists($filepath))
{
$message .= "Salon Report Custom Log File\n\n";
}
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
{
return FALSE;
}
$message .= date($this->_date_fmt). ' --> '.$msg."\n";
}else{
/* HERE YOUR LOG FILENAME YOU CAN CHANGE ITS NAME */
$filepath = $this->_log_path.'log-'.date('Y-m-d').EXT;
$message = '';
if ( ! file_exists($filepath))
{
$message .= "<"."?php if ( ! defined('BASEPATH'))
exit('No direct script access allowed'); ?".">\n\n";
}
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
{
return FALSE;
}
$message .= date($this->_date_fmt). ' --> '.$msg."\n";
}
flock($fp, LOCK_EX);
fwrite($fp, $message);
flock($fp, LOCK_UN);
fclose($fp);
@chmod($filepath, FILE_WRITE_MODE);
return TRUE;
}
}