定制 cleatsquad/logger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cleatsquad/logger

最新稳定版本:1.1.3

Composer 安装命令:

composer require cleatsquad/logger

包简介

Custom logger based in monolog

README 文档

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

Latest Stable Version Total Downloads Latest Unstable Version License

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

统计信息

  • 总下载量: 10.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-21