PHP code example of lizhichao / log2ck

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

    

lizhichao / log2ck example snippets


$db_conf             = [];
$db_conf['host']     = 'tcp://192.168.23.129:9091';
$db_conf['username'] = 'default';
$db_conf['password'] = '123456';
$db_conf['database'] = 'test1';

$table       = 'web_log';
$server_name = 'web1';

$ck = new Log2Ck(
    $db_conf, // 
    $table, // table 
    [
    'host', 'ip', 'duration', 
    'create_time', 'method', 'url', 'path', 'code', 'size', 
    'refer', 'refer_host', 'user_agent', 
    'server_name'
    ] //field name
);
$ck->regLogFn(function($row){
    // 自己解析 $row
    return $array; //和上面的字段对应
})->run();