PHP code example of ialopezg / logger

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

    

ialopezg / logger example snippets


$logger = new \ialopezg\Services\Logger([
    'log_path' => 'logs'
]);

/**
 * Log a message into the default log system. If the log system does not exists, will create a new one.
 *
 * @param int $level log message level. Accepts: `debug`, `error`, `info` and `warning` messages.
 * @param string $message log message.
 *
 * @return bool <code>true</code> if line was successfully wrote, <code>false</code> otherwise.
 */
public static function log($level, $message): bool

// debug message
Logger::log('debug', 'Debug message');
// error message
Logger::log('error', 'Error message');
// info message
Logger::log('info', 'Informative message');
// warning message
Logger::log('warning', 'Waring message');

/**
 * Write a log message line.
 *
 * @param string $level Error log level.
 * @param string $message Error log message.
 *
 * @return bool True if line was successfully wrote.
 */
public static function write($level, $message): void

// debug message
$logger->write('debug', 'Debug message');
// error message
$logger->write('error', 'Error message');
// info message
$logger->write('info', 'Informative message');
// warning message
$logger->write('warning', 'Waring message');