-
-
Save luxerama/2690211 to your computer and use it in GitHub Desktop.
Send UDP remote syslog message from PHP (RFC 3164)
This file contains 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 | |
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") { | |
$msg = "<22>" . date('M j H:i:s ') . $program . ' ' . $component . ': ' . $message; | |
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); | |
# replace these with settings provided by Papertrail | |
socket_sendto($sock, $msg, strlen($msg), 0, 'logs.papertrailapp.com', 1111); | |
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