PHP code example of yonna / log

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

    

yonna / log example snippets



    
    use Yonna\Log\FileLog;
    
    // 记录日志的「目录」
    // 你可以在scope中的$request->cargo内获取到app的根
    $root = '/your_log_dir';
    
    $log = (new FileLog($root));
    
    // 记录 Throwable 的日志
    $log->throwable($e);
    
    // 记录常规日志
    $msg = 'iam log';
    $data = [
        'a' => 1,    
        'b' => 2,    
        'c' => 3,    
    ];
    $log->error($msg,$data);
    $log->warning($msg,$data);
    $log->info($msg,$data);
    



    use Yonna\Log\Config;
    
    // 设置文件的日志目录名
    Config::setFile('app_log');