承接 midweste/simplelogger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

midweste/simplelogger

Composer 安装命令:

composer require midweste/simplelogger

包简介

SimpleLogger is a collection of very simple loggers implementing \Psr\Log\LoggerInterface (PSR-3)

README 文档

README

SimpleLogger is a collection of very simple logger classes for PHP 5.4 implementing \Psr\Log\LoggerInterface (PSR-3), the common logger interface standardized by the PHP Framework Interop Group (www.php-fig.org).

SimpleLogger is intended for small projects or testing purposes if you don't need a full-featured logging solution like Monolog.

If you just need to output a few log messages in a small PHP project but want to stick to the PSR-3 standard this package is for you. When your project grows you can simply replace it by a more advanced logging solution like Monolog.

Loggers

  • \Midweste\SimpleLogger\EchoLogger: Just echo the log message

  • \Midweste\SimpleLogger\FileLogger: Log to a file

  • \Midweste\SimpleLogger\ArrayLogger: Keep log messages in an array for later use (e.g. display it to the user)

  • \Midweste\SimpleLogger\SessionLogger: Keep log messages in a session for later use (e.g. display it to the user on another page)

  • \Midweste\SimpleLogger\ConsoleLogger: Log to the Symfony2 console => DEPRECATED: use Symfony\Component\Console\Logger\ConsoleLogger instead

Installation

  • composer require midweste/simplelogger

Usage

$logger = new \Midweste\SimpleLogger\FileLogger('/path/to/logfile');
$logger->info('This is the first log message');

NEW: it's now possible to set a minimum log level in the constructor of FileLogger, EchoLogger and ArrayLogger:

$logger = new \Midweste\SimpleLogger\FileLogger('/path/to/logfile', \Psr\Log\LogLevel::ERROR);
$logger->info('This is the first log message'); // this message will be discarded
$logger->error('This is an error message'); // this message will be logged

In one of my projects there was a "fetcher" class that fetched some information from a web service. It needed to log whether this fetch was successfull or not and how many data it fetched. It could be invoked either from the command line, by a background task, or by a user in the admin web page of the application. This was the use case for three logger classes:

  • the fetcher class itself just logs to any PSR-3 compliant logger

  • if called from a background task (cronjob), it is given a FileLogger

  • if called from the command line, it is given a ConsoleLogger

  • if called from the web interface, it is given an ArrayLogger. The output of this logger is then displayed to the user on the web page.

统计信息

  • 总下载量: 894
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固