All Projects → SeunMatt → codeigniter-log-viewer

SeunMatt / codeigniter-log-viewer

Licence: MIT license
This is a simple Log Viewer for viewing Code Igniter logs on the browser and via API clients

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to codeigniter-log-viewer

eliottree
Render Eliot logs as an ASCII tree
Stars: ✭ 58 (-27.5%)
Mutual labels:  log-viewer
Laravel Log Viewer
🐪 Laravel log viewer
Stars: ✭ 2,726 (+3307.5%)
Mutual labels:  log-viewer
CodeIgniter-HMVC
CodeIgniter 3.1.10 with Modular Extensions - HMVC and Whoops Error Handling Framework 2.5.0
Stars: ✭ 30 (-62.5%)
Mutual labels:  codeigniter
log-viewer
💻View terminal logs in browser
Stars: ✭ 75 (-6.25%)
Mutual labels:  log-viewer
Snowflake
Graphical SFTP client and terminal emulator with helpful utilities
Stars: ✭ 1,676 (+1995%)
Mutual labels:  log-viewer
Web
Source Code of www.codeigniter.org.tw
Stars: ✭ 13 (-83.75%)
Mutual labels:  codeigniter
vim-log-highlighting
Syntax highlighting for generic log files in VIM
Stars: ✭ 164 (+105%)
Mutual labels:  log-viewer
angular-openid-connect-php
Angular & PHP CodeIgniter server through OAuth 2.0 OpenID Connect
Stars: ✭ 14 (-82.5%)
Mutual labels:  codeigniter
Logviewer
📃 Provides a log viewer for Laravel
Stars: ✭ 2,098 (+2522.5%)
Mutual labels:  log-viewer
Adware-ads-network-server
Online Advertising Network Server
Stars: ✭ 44 (-45%)
Mutual labels:  codeigniter
logquacious
Logquacious (lq) is a fast and simple log viewer.
Stars: ✭ 55 (-31.25%)
Mutual labels:  log-viewer
Graylog2 Server
Free and open source log management
Stars: ✭ 5,952 (+7340%)
Mutual labels:  log-viewer
sistem skripsi
Proses skripsi menjadi lebih teratur dan cepat yang dilakukan secara online yang bisa diakses dimana saja melalui browser dengan bertujuan menghemat waktu, tenaga dan memudahkan mendapatkan informasi proses skripsi secara Online.
Stars: ✭ 23 (-71.25%)
Mutual labels:  codeigniter
Analogy.LogViewer
A customizable Log Viewer with ability to create custom providers. Can be used with C#, C++, Python, Java and others
Stars: ✭ 172 (+115%)
Mutual labels:  log-viewer
cszcms
Open Source CMS (Content Management System) with Codeigniter and Bootstrap.
Stars: ✭ 47 (-41.25%)
Mutual labels:  codeigniter
logserver
web log viewer that combines logs from several sources
Stars: ✭ 20 (-75%)
Mutual labels:  log-viewer
online-games-store
Simple e-commerce proejct built with Codeigniter 3
Stars: ✭ 49 (-38.75%)
Mutual labels:  codeigniter
portal-news
Portal news project built with Codeigniter 3
Stars: ✭ 46 (-42.5%)
Mutual labels:  codeigniter
Codeigniter-4-CRUD-generator
ADEL CCG is an easy open-source intuitive web app to create AdminLTE4 -Bootstrap 5- dashboards with CRUD operations in php.
Stars: ✭ 87 (+8.75%)
Mutual labels:  codeigniter
Kalkun
Open Source Web based SMS Manager
Stars: ✭ 186 (+132.5%)
Mutual labels:  codeigniter

CodeIgniter Log Viewer

Latest Stable Version Total Downloads License

This is a simple Log Viewer for viewing CodeIgniter logs in the browser or via API calls (that returns a JSON response)

This project is inspired by the laravel-log-viewer project.

A typical log view looks like this:

sample.png

Usage

For CodeIgniter 3, see this reference guide

Requirements

  • PHP >= 7.4
  • CodeIgniter 4

Composer Installation

composer require seunmatt/codeigniter-log-viewer

Controller Integration for Browser Display

All that is required is to execute the showLogs() method in a Controller that is mapped to a route:

A typical Controller (LogViewerController.php) will have the following content:

namespace App\Controllers;
use CILogViewer\CILogViewer;

class LogViewerController extends BaseController
{
    public function index() {
        $logViewer = new CILogViewer();
        return $logViewer->showLogs();
    }
}

Then the route app/Config/Routes.php can be configured like:

$routes->get('logs', "LogViewerController::index");

And that's all! If you visit /logs on your browser you should see all the logs that are in writable/logs folder and their content

Configuration

The package allows you to configure some of its parameters by creating a CILogViewer class in CodeIgniter's Config folder and then adding the following variables:

  • The folder path for log files can be configured with the $logFolderPath config var.

  • The file pattern for matching all the log files in the log folder can be configured by adding $logFilePattern config var.

  • The name of the view that renders the logs page can be changed using the $viewName config var. Please note that this can be a route relative to your View path or a namespace route.

Example configuration file app/Config/CILogViewer.php:

<?php
namespace Config;
use CodeIgniter\Config\BaseConfig;

class CILogViewer extends BaseConfig {
    public $logFilePattern = 'log-*.log';
    public $viewName = 'logs'; //where logs exists in app/Views/logs.php
}

Viewing Log Files via API Calls

If you're developing an API Service, powered by CodeIgniter, this library can still be used to view your log files.

Controller Setup

The setup is the same as that mentioned above:

  • Create a Controller e.g. ApiLogViewerController.php,
  • Create a function e.g. index()
  • In the function, call echo $this->logViewer->showLogs();
  • Finally, map your controller function to a route.

API Commands

The API is implemented via a set of query params that can be appended to the /logs path.

Query:

  • /logs?api=list will list all the log files available in the configured folder

Response:

{
   "status": true,
   "log_files": [
       {
           "file_b64": "bG9nLTIwMTgtMDEtMTkucGhw",
           "file_name": "log-2018-01-19.php"
       },
       {
           "file_b64": "bG9nLTIwMTgtMDEtMTcucGhw",
           "file_name": "log-2018-01-17.php"
       }
   ]
}

file_b64 is the base64 encoded name of the file that will be used in further operations and API calls

Query:

  • /logs?api=view&f=bG9nLTIwMTgtMDEtMTcucGhw will return the logs contained in the log file specified by the f parameter.

The value of the f (f stands for file) is the base64 encoded format of the log file name. It is obtained from the /logs?api=list API call. A list of all available log files is also returned.

Response:

{
    "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"
    ]
}

The API Query can also take one last parameter, sline that will determine how the logs are returned When it's true the logs are returned in a single line:

Query:

/logs?api=view&f=bG9nLTIwMTgtMDEtMTkucGhw&sline=true

Response:

{
   "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"
}

When it's false (Default), the logs are returned in as an array, where each element is a line in the log file:

Query:

/logs?api=view&f=bG9nLTIwMTgtMDEtMTkucGhw&sline=false OR logs?api=view&f=bG9nLTIwMTgtMDEtMTkucGhw

Response:

{
   
   "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"
   ]
}

Query:

/logs?api=delete&f=bG9nLTIwMTgtMDEtMTkucGhw will delete a single log file. The f parameter is the base64 encoded name of the file and can be obtained from the view api above.

Query:

/logs?api=delete&f=all will delete all log files in the configured folder path. Take note of the value for f which is the literal 'all'.

IF A FILE IS TOO LARGE (> 50MB), YOU CAN DOWNLOAD IT WITH THIS API QUERY /logs?dl=bG9nLTIwMTgtMDEtMTcucGhw

SECURITY NOTE

It is Highly Recommended that you protect/secure the route for your logs. It should not be an open resource!

Change Log

Change Log is available here

Author

Contributors

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].