承接 miladrahimi/phplogger 相关项目开发

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

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

miladrahimi/phplogger

最新稳定版本:1.6

Composer 安装命令:

composer require miladrahimi/phplogger

包简介

Free PHP logger for neat and powerful projects!

README 文档

README

A simple logger for php projects

Overview

PHP Logger is a simple package for PHP developers to log. It is implemented based on PSR-3 Standard.

Installation

Using Composer (Recommended)

Read How to use composer in php projects article if you are not familiar with Composer.

Run following command in your project root directory:

composer require miladrahimi/phplogger

Manually

You may use your own autoloader as long as it follows PSR-0 or PSR-4 standards. Just put src directory contents in your vendor directory.

Getting Started

PHPLogger has potential to store logs into different kinds of storage, but for now you can only use directory (filesystem) to store them. Following codes illustrate how to define a directory storage and inject it to Logger class:

use MiladRahimi\PHPLogger\Logger;
use MiladRahimi\PHPLogger\Directory;

$dir = new Directory("./logs/");
$logger = new Logger($dir);

As you see in the code snippet above, you can inject storage via Logger constructor, but if you want to use more storage, you may add them via following method:

$logger->addStorage($my_storage);

Now you may store your first log:

$logger->alert("This is an alert!");

Alert is not only supported log level out of the box, you may see all supported log level out there in PSR-3 page.

Log method

The broader method for logging is Logger::log() method which catches log level as its first parameter. Following example show how to use this method:

use MiladRahimi\PHPLogger\Logger;
use MiladRahimi\PHPLogger\Directory;

$directory = new Directory(__DIR__);
$logger = new Logger($directory);
$logger->log("alert", "This is an alert message!");

To follow standards you may use LogLevel constants which are provided by PSR-3 standard.

use MiladRahimi\PHPLogger\Logger;
use MiladRahimi\PHPLogger\Directory;
use Psr\Log\LogLevel;

$logger = new Logger(new Directory(__DIR__));
$logger->log(LogLevel::ALERT, "This is an error message!");

Context

Context is the third parameter in Logger::log() method and second one for direct level log methods like Log::alert(). This parameter can be an array or an object which you may use to store more details alongside your log message.

License

PHPLogger is created by Milad Rahimi and released under the MIT License.

miladrahimi/phplogger 适用场景与选型建议

miladrahimi/phplogger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「library」 「logger」 「free」 「neat」 「psr-3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 miladrahimi/phplogger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 miladrahimi/phplogger 我们能提供哪些服务?
定制开发 / 二次开发

基于 miladrahimi/phplogger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-10