All Projects → EasyCorp → Easy Log Handler

EasyCorp / Easy Log Handler

Licence: mit
Human-friendly log files that make you more productive

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Easy Log Handler

Monolog Bundle
Symfony Monolog Bundle
Stars: ✭ 2,532 (+22.32%)
Mutual labels:  symfony, log, logger, monolog
Monolog Bridge
Provides integration for Monolog with various Symfony components.
Stars: ✭ 2,238 (+8.12%)
Mutual labels:  symfony, log, monolog
monolog-sentry-handler
Monolog handler for Sentry PHP SDK v2 with breadcrumbs support
Stars: ✭ 34 (-98.36%)
Mutual labels:  monolog, logger, monolog-handler
monolog-http
A collection of monolog handlers that use a PSR-18 HTTP Client to send your logs
Stars: ✭ 34 (-98.36%)
Mutual labels:  log, monolog, monolog-handler
Yii2 Psr Log Target
Yii 2.0 log target that is able to write messages to PSR-3 compatible logger
Stars: ✭ 58 (-97.2%)
Mutual labels:  log, logger
Logger
Simple logger with stores inspector
Stars: ✭ 58 (-97.2%)
Mutual labels:  log, logger
Android Filelogger
A general-purpose logging library with built-in support to save logs to file efficiently.
Stars: ✭ 70 (-96.62%)
Mutual labels:  log, logger
Logtofile
Android一个简单实用把Log日志打印到手机本地文件,可以自行取出来上传到服务器开源代码
Stars: ✭ 74 (-96.43%)
Mutual labels:  log, logger
Loguru
Python logging made (stupidly) simple
Stars: ✭ 10,510 (+407.73%)
Mutual labels:  log, logger
Coolog
A expandable and flexible log framework for iOS. iOS一个灵活、可扩展的日志组件。
Stars: ✭ 82 (-96.04%)
Mutual labels:  log, logger
Serverlog
A simple, practical and innovative Node.js log library that enables you to view logs in Chrome dev tools and browser Console.
Stars: ✭ 117 (-94.35%)
Mutual labels:  log, logger
Plog
Portable, simple and extensible C++ logging library
Stars: ✭ 1,061 (-48.74%)
Mutual labels:  log, logger
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-97.54%)
Mutual labels:  log, logger
Signale
Highly configurable logging utility
Stars: ✭ 8,575 (+314.25%)
Mutual labels:  log, logger
Logutils
More convenient and easy to use android Log manager
Stars: ✭ 1,035 (-50%)
Mutual labels:  log, logger
Logcustom
A simple log customization tool based on golang 一个基于golang简单的日志定制化工具
Stars: ✭ 46 (-97.78%)
Mutual labels:  log, logger
Node Lambda Log
Basic logging mechanism for Node 6.10+ Lambda Functions
Stars: ✭ 115 (-94.44%)
Mutual labels:  log, logger
Easylogger
An ultra-lightweight(ROM<1.6K, RAM<0.3k), high-performance C/C++ log library. | 一款超轻量级(ROM<1.6K, RAM<0.3k)、高性能的 C/C++ 日志库
Stars: ✭ 1,968 (-4.93%)
Mutual labels:  log, logger
Go Logger
一个简单而强大的 golang 日志工具包,支持同步和异步输出到 命令行,文件, api 接口,文件支持按文件大小,文件行数,日期切分;A simple and powerful golang logging toolkit that supports synchronous and asynchronous output to the console, file, API interfaces, file support by file size, file line number, date sharding.
Stars: ✭ 152 (-92.66%)
Mutual labels:  log, logger
Loglevelnext
A modern logging library for Node.js that provides log level mapping to the console
Stars: ✭ 33 (-98.41%)
Mutual labels:  log, logger

EasyLogHandler (human-friendly log files)

Symfony log files are formatted in the same way for all environments. This means that dev.log is optimized for machines instead of humans. The result is a log file bloated with useless information that makes you less productive.

EasyLogHandler is a new Monolog handler that creates human-friendly log files. It's optimized to display the log information in a clear and concise way. Use it in the development environment to become a much more productive developer.

  1. Features
  2. Installation
  3. Configuration and Usage

Features

These are some of the best features of EasyLogHandler and how it compares itself with the default Symfony logs.

Better Log Structure

Symfony log files are a huge stream of text. When you open them, you can't easily tell when a request started or finished and which log messages belong together:

Symfony EasyLogHandler
structure-overview-symfony-mini structure-overview-easylog-mini

EasyLogHandler structures the log files in a different way:

structure-easylog

  • It adds a large header and some new lines to separate each request logs;
  • If the request is less significant (e.g. Assetic requests) the header is more compact and displays less information;
  • Log messages are divided internally so you can better understand their different parts (request, doctrine, security, etc.)

Less Verbose Logs

First of all, EasyLogHandler doesn't display the timestamp in every log message. In the dev environment you shouldn't care about that, so the timestamp is only displayed once for each group of log messages.

Symfony EasyLogHandler
timestamps-symfony timestamps-easylog

The extra information, which some log messages include to add more details about the log, is displayed only when it's different from the previous log. In contrast, Symfony always displays the extra for all logs, generating a lot of duplicated information:

Symfony
extra-symfony
EasyLogHandler
extra-easylog

It's becoming increasingly popular to use placeholders in log messages instead of the actual values (e.g. Matched route "{route}". instead of Matched route "home".) This is great for machines, because they can group similar messages that only vary in the placeholder values.

However, for humans this "feature" is disturbing. That's why EasyLogHandler automatically replaces any placeholder included in the log message:

Symfony
placeholders-symfony
EasyLogHandler
placeholder-easylog

Better Visual Hierarchy

Important elements, such as deprecations and security-related messages, must stand out in log files to help you spot them instantly. However, in Symfony all logs look exactly the same. How can you know which are the important ones?

Symfony
visual-hierarchy-symfony
(all messages look exactly the same)
EasyLogHandler
visual-hierarchy-easylog
(deprecations, warnings, errors and security messages stand out)

Dynamic Variable Inlining

Log messages usually contain related variables in their context and extra properties. Displaying the content of these variables in the log files is always a tough balance between readability and conciseness.

EasyLogHandler decides how to inline these variables dynamically depending on each log message. For example, Doctrine query parameters are always inlined but request parameters are inlined for unimportant requests and nested for important requests:

dynamic-inline-easylog

Stack Traces

When log messages include error stack traces, you definitely want to take a look at them. However, Symfony displays stack traces inlined, making them impossible to inspect. EasyLogHandler displays them as proper stack traces:

Symfony
stack-trace-symfony
EasyLogHandler
stack-trace-easylog

Log Message Grouping

One of the most frustrating experiences when inspecting log files is having lots of repeated or similar consecutive messages. They provide little information and they just distract you. EasyLogHandler process all log messages at once instead of one by one, so it's aware when there are similar consecutive logs.

For example, this is a Symfony log file displaying three consecutive missing translation messages:

translation-group-symfony

And this is how the same messages are displayed by EasyLogHandler:

translation-group-easylog

The difference is even more evident for "event notified" messages, which usually generate tens of consecutive messages:

Symfony
event-group-symfony
EasyLogHandler
event-group-easylog

Installation

This project is distributed as a PHP package instead of a Symfony bundle, so you just need to require the project with Composer:

$ composer require --dev easycorp/easy-log-handler

Configuration and Usage

Step 1

Define a new service in your application for this log handler:

Newer Symfony version:

# config/packages/dev/easy_log_handler.yaml
services:
    EasyCorp\EasyLog\EasyLogHandler:
        public: false
        arguments: ['%kernel.logs_dir%/%kernel.environment%.log']

Older Symfony version:

# app/config/services.yml
services:
    # ...
    easycorp.easylog.handler:
        class: EasyCorp\EasyLog\EasyLogHandler
        public: false
        arguments:
            - '%kernel.logs_dir%/%kernel.environment%.log'

Step 2

Update your Monolog configuration in the dev environment to define a buffered handler that wraps this new handler service (keep reading to understand why). You can safely copy+paste this configuration:

Newer Symfony version:

# config/packages/dev/monolog.yaml
monolog:
    handlers:
        buffered:
            type:     buffer
            handler:  easylog
            channels: ['!event']
            level:    debug
        easylog:
            type: service
            id:   EasyCorp\EasyLog\EasyLogHandler

Older Symfony version:

# app/config/config_dev.yml
monolog:
    handlers:
        buffered:
            type:     buffer
            handler:  easylog
            channels: ["!event"]
            level:    debug
        easylog:
            type: service
            id:   easycorp.easylog.handler

Most log handlers treat each log message separately. In contrast, EasyLogHandler advanced log processing requires each log message to be aware of the other logs (for example to merge similar consecutive messages). This means that all the logs associated with the request must be captured and processed in batch.

In the above configuration, the buffered handler saves all log messages and then passes them to the EasyLog handler, which processes all messages at once and writes the result in the log file.

Use the buffered handler to configure the channels logged/excluded and the level of the messages being logged.

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].