Giter VIP home page Giter VIP logo

hgati / logger Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cleatsquad/logger

0.0 0.0 0.0 40 KB

This package allows you to send logs to files. based on monolog/monolog. You can use it during your development to make debugging easier. The file are in the var / log folder. This package is recommended for magento 2.This package allows you to send logs to files.

License: MIT License

PHP 100.00%

logger's Introduction

Custom Logger for Magento 2 - Alternative Mage::log() ~

This package allows you to send logs to files. based on monolog/monolog. You can use it during your development to make debugging easier. The file are in the var/log folder. the name is logger.log by default. This package is recommended for magento 2.

Badges

Latest Stable Version Total Downloads Latest Unstable Version License

Getting Started

Installing

Add dependency

composer require hgati/logger

Examples

You can use it in your php class like this

\CleatSquad\Logger::log('Hello!!', 'test.log');
\CleatSquad\Logger::log('Hello!!', 'test.log', \Monolog\Logger::WARNING);
\CleatSquad\Logger::log([22 => 'is an array'], 'test.log');
\CleatSquad\Logger::info(['is an array'], 'test.log');

try {
    throw new \Exception('Error message');
} catch (\Exception $exception) {
    \CleatSquad\Logger::critical($exception);
}

From 1.1.2 you can use the magic log method below examples

_log('Hello!!', 'test.log');
_log('Hello!!', 'test.log', \Monolog\Logger::WARNING);
_log([22 => 'is an array'], 'test.log');
_log(['is an array'], 'test.log', \Monolog\Logger::INFO);

try {
    throw new \Exception('Error message');
} catch (\Exception $exception) {
    _log($exception);
}

Results

test.log

[2021-11-21 14:17:44] logger.DEBUG: Hello!! [] []
[2021-11-21 14:17:44] logger.WARNING: Hello!! [] []
[2021-11-21 14:17:44] logger.DEBUG: Array (  [22] => is an array )  [] []
[2021-11-21 14:17:44] logger.INFO: Array (  [0] => is an array )  [] []
[2021-11-21 14:22:40] logger.CRITICAL: Exception: Error message in /var/www/html/pub/index.php:37 Stack trace: #0 {main} [] []

Log Levels

Monolog supports the logging levels described by RFC 5424.

  • DEBUG (100): Detailed debug information.

  • INFO (200): Interesting events. Examples: User logs in, SQL logs.

  • NOTICE (250): Normal but significant events.

  • WARNING (300): Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

  • ERROR (400): Runtime errors that do not require immediate action but should typically be logged and monitored.

  • CRITICAL (500): Critical conditions. Example: Application component unavailable, unexpected exception.

  • ALERT (550): Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

  • EMERGENCY (600): Emergency: system is unusable.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Mohamed El Mrabet - Initial work - mimou78

License

This project is licensed under the MIT License - see the LICENSE.md file for details

logger's People

Contributors

mimou78 avatar hgati avatar

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.