cleatsquad / logger
Custom logger based in monolog
Installs: 5 151
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.4.0
- monolog/monolog: >=1.17.0
This package is auto-updated.
Last update: 2024-10-19 15:32:48 UTC
README
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.
Badges
Getting Started
Installing
Add dependency
composer require cleatsquad/logger ^1.1
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