forked from parse-community/parse-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseLogs.php
More file actions
89 lines (79 loc) · 2.58 KB
/
Copy pathParseLogs.php
File metadata and controls
89 lines (79 loc) · 2.58 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
81
82
83
84
85
86
87
88
89
<?php
/**
* Class ParseLogs | Parse/ParseLogs.php
*/
namespace Parse;
/**
* Class ParseLogs - Allows access to server side parse script logs
*
* @author Ben Friedman <friedman.benjamin@gmail.com>
* @package Parse
*/
class ParseLogs
{
/**
* Requests script logs from the server
*
* @param string $level Level of logs to return (info/error), default is info
* @param int $size Number of rows to return, default is 100
* @param null $from Earliest logs to return from, defaults to 1 week ago
* @param null $until Latest logs to return from, defaults to current time
* @param null $order Order to sort logs by (asc/desc), defaults to descending
* @return array
*/
public static function getScriptLogs(
$level = 'info',
$size = 100,
$from = null,
$until = null,
$order = null
) {
$data = [
'level' => $level,
'size' => $size,
];
if (isset($from) && $from instanceof \DateTime) {
$data['from'] = ParseClient::getProperDateFormat($from);
}
if (isset($until) && $until instanceof \DateTime) {
$data['until'] = ParseClient::getProperDateFormat($until);
}
if (isset($order)) {
$data['order'] = $order;
}
$response = ParseClient::_request(
'GET',
'scriptlog',
null,
$data,
true
);
return $response;
}
/**
* Returns info logs
*
* @param int $size Lines to return, 100 by default
* @param null $from Earliest logs to return from, default is 1 week ago
* @param null $until Latest logs to return from, defaults to current time
* @param null $order Order to sort logs by (asc/desc), defaults to descending
* @return array
*/
public static function getInfoLogs($size = 100, $from = null, $until = null, $order = null)
{
return self::getScriptLogs('info', $size, $from, $until, $order);
}
/**
* Returns error logs
*
* @param int $size Lines to return, 100 by default
* @param null $from Earliest logs to return from, default is 1 week ago
* @param null $until Latest logs to return from, defaults to current time
* @param null $order Order to sort logs by (asc/desc), defaults to descending
* @return array
*/
public static function getErrorLogs($size = 100, $from = null, $until = null, $order = null)
{
return self::getScriptLogs('error', $size, $from, $until, $order);
}
}