-
Notifications
You must be signed in to change notification settings - Fork 2
/
klogger.php
67 lines (54 loc) · 1.88 KB
/
klogger.php
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
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class klogger {
//put your code here
var $location = '/tmp/';
var $trackId = "";
public function __construct() {
$this->location .= "whatsapp-" . Date('Y-m-d-H') . ".log";
$this->trackId = $this->getTrackId();
$a = func_get_args();
$i = func_num_args();
if (method_exists($this, $f = '__construct' . $i)) {
call_user_func_array(array($this, $f), $a);
}
$this->setErrorFile();
}
private function getTrackId() {
if (!isset($_SESSION["trackId"])) {
$_SESSION["trackId"] = time();
}
$trackId = $_SESSION["trackId"];
return Date('Y-m-d H:i:s') . "-" . $trackId;
}
public function setTrackId($trackId = "1") {
$_SESSION["trackId"] = $trackId;
$this->trackId = $this->getTrackId();
}
public function __construct1($file) {
$this->location .="$file";
}
public function debug($msg = null) {
error_log("DEBUG: " . $this->trackId . " " . $msg . "\n", 3, $this->location);
}
public function error($msg = null) {
error_log("ERROR: " . $this->trackId . " " . $msg . "\n", 3, $this->location);
}
public function info($msg = null) {
error_log("INFO: " . $this->trackId . " " . $msg . "\n", 3, $this->location);
}
private function setErrorFile() {
// if(!isset($_SESSION['__is_log_error_set'])){
ini_set('log_errors', TRUE);
ini_set('error_log', $this->location);
$_SESSION['__is_log_error_set'] = 1;
// }
}
public function flow_debug($msg = null) {
error_log("DEBUG:FlOW " . $this->trackId . " " . $msg . "\n", 3, $this->location);
}
}