1. Go to this page and download the library: Download irap/logging library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
irap / logging example snippets
$udpLogger = new \iRAP\Logging\UdpLogger("192.168.1.1", 1234);
$udpLogger->alert("This is my alert message", ['time' => time()]);
# Create a callback for handling the captured UDP log
$logHandler = function($from, $message, $logLevel, $context) {
print "{$from} ({$logLevel}): {$message}" . PHP_EOL;
print "context: " . print_r($context, true) . PHP_EOL . PHP_EOL;
// now do something else like log it to the database.
};
# Createthe UDP reciever which will listen for logs
$udpReciever = new iRAP\Logging\UdpLogReciever(
$maxLength = 1024*1024*32,
1234,
$logHandler
);
# Call the listen() to listen for UDP logs.
print "listening for messages..." . PHP_EOL;
while (true)
{
$udpReciever->listen();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.