PhealLogger   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 25
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 0 1 1
A stop() 0 1 1
A log() 0 4 1
A errorLog() 0 11 3
1
<?php
2
/* zKillboard
3
 * Copyright (C) 2012-2015 EVE-KILL Team and EVSCO.
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
class PhealLogger implements \Pheal\Log\CanLog
20
{
21
	private $logID = null;
0 ignored issues
show
Unused Code introduced by
The property $logID is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
22
23
	public function start() {}
24
25
	public function stop() {}
26
27
	public function log($scope,$name,$opts) {
28
		Db::execute("insert into zz_api_log (scope, name, options) values (:scope, :name, :options)",
29
				array(":scope" => $scope, ":name" => $name, ":options" => json_encode($opts)));
30
	}
31
32
	public function errorLog($scope,$name,$opts,$message) {
33
		Db::execute("insert into zz_api_log (scope, name, options, errorCode) values (:scope, :name, :options, :error)",
34
				array(":scope" => $scope, ":name" => $name, ":options" => json_encode($opts), ":error" => substr($message, 0, 127)));
35
		if (Util::startsWith($message, "904:"))
36
		{
37
			global $debug;
38
			Db::execute("replace into zz_storage values ('ApiStop904', date_add(now(), interval 5 minute))");
39
			if ($debug) Log::log("Killing API transactions in this thread: $message");
40
			die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method errorLog() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
41
		}
42
	}
43
}
44