- ED25519 private SSL key
- Signed certificate
- CA certificate
<?php
use Webbmaffian\Logger\Logger;
use Webbmaffian\Logger\TlsClient;
// Named arguments work since PHP 8.0
$client = new TlsClient(
host: '127.0.0.1',
port: 4610,
caCertPath: 'ca.pem',
certPath: 'cert.pem',
privKeyPath: 'key.pem',
);
$logger = new Logger($client);<?php
use Webbmaffian\Logger\Logger;
use Webbmaffian\Logger\TlsClient;
use Webbmaffian\Logger\Directory;
// Named arguments work since PHP 8.0
$client = new TlsClient(
host: '127.0.0.1',
port: 4610,
caCertPath: 'ca.pem',
certPath: 'cert.pem',
privKeyPath: 'key.pem',
);
// Use a directroy as fallback. When the fallback occurs, the directory will be filled with up to 1 file per minute.
$fallback = new Directory('logs');
$logger = new Logger($client, $fallback);
// Whenever suitable, transfer the log entries from the fallback client to the main client. If there are no entries
// in the fallback client, nothing will happen.
$logger->transferFromFallback();$logger->info('Hello world');$logger->info('Hello world', 'tag1', 'tag2');$logger->info('Foo %s bar', 'tag1', 'tag2');$logger->info('Order %d failed', $orderNumber, [
'something' => 'foobar',
'somethingElse' => 1234,
]);$entryId = $logger->err('Oopsie daisy');
// Give the ID to the user so that the development team can look it up
echo $entryId;<?php
use Webbmaffian\Logging\Error;
try {
// Severity 'error'
throw new Error('Order %d failed', $orderNumber, [
'something' => 'foobar',
'somethingElse' => 1234,
]);
} catch(Error $e) {
// The whole log entry is contained in the exception, so just send
$logger->send($e);
}try {
throw new Exception('Something happened');
} catch(Exception $e) {
// Other exceptions have no severity level - log the usual way
$logger->err($e);
}<?php
use Webbmaffian\Logging\Error;
try {
// Severity 'error'
throw new Error('Order %d failed', $orderNumber, [
'something' => 'foobar',
'somethingElse' => 1234,
]);
} catch(Error $e) {
// The exception itself contains the entry ID
$entryId = $e->getId();
// When sending an entry, the ID is also returned
$entryId = $logger->send($e);
// Give the ID to the user so that the development team can look it up
echo $entryId;
}| Level | Name | Description | Log | Throw |
|---|---|---|---|---|
| 0 | Emergency | System is unusable - everybody panic | $logger->emerg() |
new Emergency() |
| 1 | Alert | Action must be taken immediately E.g: corrupted system database, backup failures, etc. |
$logger->alert() |
new Alert() |
| 2 | Critical | Critical condition that prevents a specific task E.g: fatal error, broken pages, etc. |
$logger->crit() |
new Critical() |
| 3 | Error | Non-critical errors, but that must be fixed. E.g: failed API requests, etc. |
$logger->err() |
new Error() |
| 4 | Warning | Warnings about unexpected conditions that might lead to errors further on E.g: "this shouldn't be possible, but let's check it any way" |
$logger->warn() |
new Warning() |
| 5 | Notice | Normal but significant conditions E.g: undefined variables, and other problems that were maneuvered but should be prevented |
$logger->notice() |
new Notice() |
| 6 | Info | Informational events of normal operations E.g: taken actions, form validation, blocked requests, user errors, etc. |
$logger->info() |
- |
| 7 | Debug | Helpful information for troubleshooting E.g: anything verbose |
$logger->debug() |
- |