1. Go to this page and download the library: Download cbschuld/logentries 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/ */
cbschuld / logentries example snippets
php
use cbschuld\LogEntries;
6435882e1f"; // your LogEntries token (sample from docs)
$log = LogEntries::getLogger($token,true,true); // create persistent SSL-based connection
$log->info("some information");
$log->notice(json_encode(["status"=>"ok","message"=>"send some json"]));
php
use cbschuld\LogEntries;
6435882e1f"; // your LogEntries token (sample from docs)
$jsonInfo = ["json"=>true,"example"=>"yes","works"=>true];
$log = LogEntries::getLogger($token,true,true); // create persistent SSL-based connection
$log->info(["status"=>"ok","example"=>"with json messages"]);
$log->notice($jsonInfo);
php
use cbschuld\LogEntries;
6435882e1f"; // your LogEntries token (sample from docs)
$jsonInfo = ["json"=>true,"example"=>"yes","works"=>true];
$log = new LogEntries($token,true,true); // create persistent SSL-based connection
$log->info(["status"=>"ok","example"=>"with json messages"]);
$log->notice($jsonInfo);
$token2 = "2bfbea1e-10c3-4419-bdad-7e6435882e1f"; // your LogEntries token (sample from docs)
$log2 = new LogEntries($token2,true,true); // create persistent SSL-based connection
$log2->info(["status"=>"ok","example"=>"with json messages","from"=>"log2"]);
$log2->notice($jsonInfo);
php
use cbschuld\LogEntries;
use cbschuld\LogEntriesWriter;
class WriterTest extends LogEntriesWriter {
// always add the hostname
public function log($message,$isJson=false) {
if($isJson) {
$json = json_decode($message,true);
$json["hostname"] = gethostname();
$message = json_encode($json);
}
else {
$hostname = gethostname();
$message .= " hostname={$hostname}";
}
return $message;
}
}
$writer = new WriterTest();
$json = array(
"datetime" => new \DateTime("now"),
"status" => "ok",
);
$log = new LogEntries("MYTOKEN",true,true);
$log->addWriter($writer);
$log->info($json);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.