PHP code example of struktal / struktal-logger

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

    

struktal / struktal-logger example snippets


\struktal\Logger\Logger::setLogDirectory("/path/to/logs/");
\struktal\Logger\Logger::setMinLogLevel(\struktal\Logger\LogLevel::TRACE);

\struktal\Logger\Logger::addCustomLogHandler(
    \struktal\Logger\LogLevel::ERROR,
    function(string $formattedMessage, string $serializedMessage, mixed $originalMessage) {
        // Custom log handler logic here
    }
);

$logger = new \struktal\Logger\Logger("custom-tag");

$logger->trace("This is a trace message");
$logger->debug("This is a debug message");
$logger->info("This is an info message");
$logger->warn("This is a warning message");
$logger->error("This is an error message");
$logger->fatal("This is a fatal message");