Giter Site home page Giter Site logo

symfony-log-viewer's Introduction

LogViewer for Symfony 5.x

Installation

  • composer require kira0269/symfony-log-viewer

Configuration

Add these lines in config/routes/kira_log_viewer.yaml :

kira_log_viewer:
    resource: "@LogViewerBundle/Resources/config/routes.yaml"
    prefix:   /logs

And these lines in config/packages/kira_log_viewer.yaml :

kira_log_viewer:
    #logs_dir: '%kernel.logs_dir%' - You can uncommented and edit this line to search logs somewhere else.

    file_pattern:
        date_format: 'Y-m-d'

    log_pattern: '\[<date>\] <channel>\.<level>: <message> <context> <extra>'

    groups:
        date:
            regex: '.*'
            type: date
        channel:
            regex: '[a-z_]+'
            type: text
        level:
            regex: '[A-Z]+'
            type: text
        message:
            regex: '.*'
        context:
            regex: (?'array1'\[(?>(?>[^[\]]+)|(?&array1))*\])|(?'object1'{(?>(?>[^{}]+)|(?&object1))*}) # match array1 or object1
            type: json
        extra:
            regex: (?'array2'\[(?>(?>[^[\]]+)|(?&array2))*\]) # match array2
            type: json
            
    dashboard:
        date: 'yesterday'
        metrics_per_row: 3
        metrics:
            logs_of_day:
                title: Daily
                type: counter
                color: blue-600
                icon: fa-calendar-check
                filters:
                    level: [ INFO ]
                    channel: [ 'security' ]
                    message: [ 'login' ]
            notice:
                title: Notice
                color: yellow-600
                icon: fa-calendar-check
                filters:
                    level: [ NOTICE ]
            info:
                title: Info
                color: green-600
                icon: fa-calendar-check
                filters:
                    level: [ INFO ]
            debug:
                title: Debug
                color: gray-600
                icon: fa-calendar-check
                filters:
                    level: [ DEBUG ]
            error:
                title: Error
                color: red-600
                icon: fa-calendar-check
                filters:
                    level: [ ERROR ]
            all_logs:
                title: All
                color: indigo-600
                icon: fa-calendar-check

Usage

Inject the LogParserInterface into your Controller/Service and parse your logs :

class DefaultController extends AbstractController
{

    public function logsOfTheDay(LogParserInterface $logParser): Response
    {
        $date = new DateTime('now');
        $logs = $logParser->parseLogs($date);
        ...
    }

}

Dashboard configuration

Define how many metrics should be displayed per row

metrics_per_row: integer

Define dashboard date filter

date: string (`today` or `yesterday` or `-6 day`)

Add custom blocks with parameters :

title: title of your block
type: counter by default
icon: fontawesome icon
color: tailwind css color of the block title and figure
filters: array of filters depending on groups names

Filters examples :

level: array of severity levels (case sensitive)
date: array of dates, ie. `today` or `yesterday` or `-6 day`
channel: array ie. `security` or 'authentication`
message: array of regexes that match the log message
extra: array of regexes that match the log extra message

symfony-log-viewer's People

Contributors

kira0269 avatar rlemoine avatar

Watchers

 avatar  avatar

symfony-log-viewer's Issues

Symfony 6 support

Hello. is there any chance that bundle will be updated in order to support Symfony ^6.* ?

Installation issue

Hello. When trying to install bundle using docs - error appear in console
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.