-
-
Save jeffwray/8561731 to your computer and use it in GitHub Desktop.
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
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") { | |
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); | |
foreach(explode("\n", $message) as $line) { | |
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line; | |
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, 'logs.papertrailapp.com', MY_PORT); | |
} | |
socket_close($sock); | |
} | |
send_remote_syslog("Test"); | |
# send_remote_syslog("Any log message"); | |
# send_remote_syslog("Something just happened", "other-component"); | |
# send_remote_syslog("Something just happened", "a-background-job-name", "whatever-app-name"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment