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; |
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(); |
|
|
|
|
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
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.