PHP code example of gokhankurtulus / logger

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

    

gokhankurtulus / logger example snippets


use Logger\Logger;

Logger::setFolderPath(__DIR__ . DIRECTORY_SEPARATOR . 'Logs');
Logger::setFileName('app.log');
Logger::iniSet(true, false, E_ALL);

Logger::log('this is app log message', 'this is log title');

[01-01-2024 15:00:00 - Europe/Istanbul] - this is log title
this is log message

class PDOLogger extends \Logger\Logger
{
    protected static string $folderPath = "";
    protected static string $fileName = "";
}

use Logger\Logger;

Logger::setFolderPath(__DIR__ . DIRECTORY_SEPARATOR . 'Logs');
Logger::setFileName('app.log');

// for log_errors, display_errors, error_reporting and
// error_log will be Logger::getFolderPath() . DIRECTORY_SEPARATOR . Logger::getFileName()
Logger::iniSet(true, false, E_ALL);

// You can give specific path for classes,
// by default it will be Logger's folder path
PDOLogger::setFolderPath(__DIR__ . DIRECTORY_SEPARATOR . 'DBLogs');
PDOLogger::setFileName('pdo.log');

Logger::log('this is app log message', 'this is log title');
PDOLogger::log('this is pdo log message');

[01-01-2024 15:00:00 - Europe/Istanbul] - this is log title
this is app log message

[01-01-2024 15:00:00 - Europe/Istanbul] - 
this is pdo log message

Logger::log();
Logger::iniSet();
Logger::setFolderPath();
Logger::getFolderPath();
Logger::setFileName();
Logger::getFileName();