Last active
April 27, 2017 19:52
-
-
Save jrobinsonc/01728fc6d08a9f66bde61df7c0c4b67e to your computer and use it in GitHub Desktop.
debugging tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Using Loggly | |
* https://www.loggly.com/ | |
*/ | |
define('LOGGLY_ENDPOINT', 'http://logs-00.loggly.com/inputs/s59tg6b3-sd59-85de-d5d4-f5s96ty36caa'); | |
function loggly_log($tag, $log) | |
{ | |
$opts = [ | |
'http' => [ | |
'method' => 'POST', | |
'header' => implode("\r\n", [ | |
'Content-type: application/json' | |
]), | |
'content' => json_encode($log) | |
] | |
]; | |
return file_get_contents(sprintf(LOGGLY_ENDPOINT . '/tag/%s/', $tag), false, stream_context_create($opts)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Using Papertrail | |
* https://papertrailapp.com/ | |
* | |
* @see http://help.papertrailapp.com/ | |
*/ | |
define('PAPERTRAIL_ENDPOINT', 'logs0.papertrailapp.com:12345'); | |
function papertrail_log($log, $component = 'staging', $program = 'MyMagicApp') | |
{ | |
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); | |
$endpoint = parse_url(PAPERTRAIL_ENDPOINT); | |
foreach(explode("\n", $log) as $line) { | |
$log_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line; | |
socket_sendto($sock, $log_message, strlen($log_message), 0, $endpoint['host'], $endpoint['port']); | |
} | |
socket_close($sock); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Using Slack | |
* https://slack.com/ | |
*/ | |
define('SLACK_ENDPOINT', 'https://hooks.slack.com/services/asdfasdfasd...'); | |
function slack_log($log) | |
{ | |
$opts = [ | |
'http' => [ | |
'method' => 'POST', | |
'header' => 'Content-type: application/json', | |
'content' => json_encode($log) | |
] | |
]; | |
$result = file_get_contents(SLACK_ENDPOINT, false, stream_context_create($opts)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment