This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathraven
executable file
·90 lines (71 loc) · 2.11 KB
/
raven
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
90
#!/usr/bin/env php
<?php
// Maximize error reporting
error_reporting(E_ALL | E_STRICT);
// TODO: if we could get rid of this and have composer figure things out it'd make it
// a bit more sane
require(dirname(__file__) . '/../lib/Raven/Autoloader.php');
Raven_Autoloader::register();
function raven_cli_test($command, $args)
{
// Do something silly
try {
throw new Exception('This is a test exception sent from the Raven CLI.');
} catch (Exception $ex) {
return $ex;
}
}
function cmd_test($dsn)
{
if (empty($dsn)) {
exit('ERROR: Missing DSN value');
}
// Parse DSN as a test
try {
$parsed = Raven_Client::parseDSN($dsn);
} catch (InvalidArgumentException $ex) {
exit("ERROR: There was an error parsing your DSN:\n " . $ex->getMessage());
}
$client = new Raven_Client($dsn, array(
'trace' => true,
'curl_method' => 'sync',
'app_path' => realpath(__DIR__ . '/..'),
'base_path' => realpath(__DIR__ . '/..'),
));
$config = get_object_vars($client);
$required_keys = array('server', 'project', 'public_key', 'secret_key');
echo "Client configuration:\n";
foreach ($required_keys as $key) {
if (empty($config[$key])) {
exit("ERROR: Missing configuration for $key");
}
if (is_array($config[$key])) {
echo "-> $key: [".implode(", ", $config[$key])."]\n";
} else {
echo "-> $key: $config[$key]\n";
}
}
echo "\n";
echo "Sending a test event:\n";
$ex = raven_cli_test("command name", array("foo" => "bar"));
$event_id = $client->captureException($ex);
echo "-> event ID: $event_id\n";
$last_error = $client->getLastError();
if (!empty($last_error)) {
exit("ERROR: There was an error sending the test event:\n " . $last_error);
}
echo "\n";
echo "Done!";
}
function main() {
global $argv;
$cmd = $argv[1];
switch ($cmd) {
case 'test':
cmd_test(@$argv[2]);
break;
default:
exit('Usage: raven test <dsn>');
}
}
main();