PHP code example of duongnhathao / codeigniter-log-viewer

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

    

duongnhathao / codeigniter-log-viewer example snippets


private $logViewer;

public function __construct() {
    parent::__construct(); 
    $this->logViewer = new \CILogViewer\CILogViewer();
    //...
}

public function index() {
    echo $this->logViewer->showLogs();
    return;
}

$route['logs'] = "logViewerController/index";
json
{
    "status": true,
    "log_files": [
        {
            "file_b64": "bG9nLTIwMTgtMDEtMTkucGhw",
            "file_name": "log-2018-01-19.php"
        },
        {
            "file_b64": "bG9nLTIwMTgtMDEtMTcucGhw",
            "file_name": "log-2018-01-17.php"
        }
    ]
}
json
 {
     "log_files": [
         {
             "file_b64": "bG9nLTIwMTgtMDEtMTkucGhw",
             "file_name": "log-2018-01-19.php"
         },
         {
             "file_b64": "bG9nLTIwMTgtMDEtMTcucGhw",
             "file_name": "log-2018-01-17.php"
         }
     ],
     "status": true,
     "logs": [
         "ERROR - 2018-01-23 07:12:31 --> 404 Page Not Found: admin/Logs/index",
         "ERROR - 2018-01-23 07:12:37 --> 404 Page Not Found: admin//index",
         "ERROR - 2018-01-23 15:23:02 --> 404 Page Not Found: Faviconico/index"
     ]
 }
 
json
{
    "log_files": [
        {
            "file_b64": "bG9nLTIwMTgtMDEtMTkucGhw",
            "file_name": "log-2018-01-19.php"
        },
        {
            "file_b64": "bG9nLTIwMTgtMDEtMTcucGhw",
            "file_name": "log-2018-01-17.php"
        }
    ],
    "status": true,
    "logs": "ERROR - 2018-01-23 07:12:31 --> 404 Page Not Found: admin/Logs/index\r\nERROR - 2018-01-23 07:12:37 --> 404 Page Not Found: admin//index\r\nERROR - 2018-01-23 15:23:02 --> 404 Page Not Found: Faviconico/index\r\n"
}
json
{
    
    "logs": [
        "ERROR - 2018-01-23 07:12:31 --> 404 Page Not Found: admin/Logs/index",
        "ERROR - 2018-01-23 07:12:37 --> 404 Page Not Found: admin//index",
        "ERROR - 2018-01-23 15:23:02 --> 404 Page Not Found: Faviconico/index"
    ]
}