PHP code example of rcezea / httplogger

1. Go to this page and download the library: Download rcezea/httplogger 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/ */

    

rcezea / httplogger example snippets


public function __construct(
    ?string $appId = NULL,
    ?string $secretKey = NULL,
    bool $logToFile = FALSE,
    ?string $logDir = NULL
)


use Rcezea\HttpLogger\HttpLogger;
use Tracy\Debugger;
use Tracy\ILogger

// Initialize Logger
$logger = new HttpLogger(
    appId: 'myAppId',
    secretKey: 'mySecretKey',
    logToFile: true
);

// Set optional configurations
HttpLogger::setEndpoint('https://api.example.com/logs');
HttpLogger::setPlatform('mobile');
HttpLogger::setMode(Debugger::Production);

// Log an exception
try {
    throw new \Exception('Something went wrong!');
} catch (\Throwable $e) {
    $logger->log($e, ILogger::ERROR);
}

// Log a message
$logger->log('This is an informational message.', ILogger::INFO);