carlosafonso/logga 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

carlosafonso/logga

Composer 安装命令:

composer require carlosafonso/logga

包简介

A logging library for PHP designed for simplicity and ease of use

关键字:

README 文档

README

Latest Stable Version Build Status Total Downloads License

Logga is a logging library for PHP designed for simplicity and ease of use. Starting from v1.0.0, Logga features support for multiple logging streams and message formatters, providing developers with great flexibility.

Current version features a file stream and a default formatter. Future releases of Logga will have a Database stream out of the box, as well as a plugin system to allow developers to write custom streams and formatters so that pretty much every logging need is covered.

##Installation ###Composer Since version 2.0.0 Logga can be installed using Composer. Add the following dependency to your composer.json:

{
  "require": {
    "carlosafonso/logga": "3.*",
  }
}

Then run:

$ composer update

Don't forget to include Composer's autoload file if you haven't done so already:

require 'vendor/autoload.php':

###Manual installation Logga can also be installed by downloading the latest version and unzipping everything into your project folder, or by cloning the repository:

$ git clone https://github.com/carlosafonso/logga.git

Remember to include the main library file into your project:

require 'logga.php';

##Quick start Set up a quick logger with the following code:

$l = new \Logga\Logga();
$l->info('Hello world!');

If you run this code, the following line will be printed on screen:

[2014-02-15 17:42:14][INFO   ]: Hello world!

Furthermore, a file named something like default_log.log will appear in the folder you're running your script from. A quick look into it reveals the same content shown above.

And that's pretty much it! You have set up your logging system with just a couple of lines. From now on you can trace everything you need using any of the eight logging functions provided by Logga (debug(), info(), notice(), warning(), error(), critical(), alert() and emergency()).

##Usage The above is simple enough for the average developer but you might want to customize Logga a bit in order to fulfill your needs. This section will show you how.

###Understanding streams In Logga, as in other logging libraries, a stream is an abstraction of a place where log messages are stored. You can use as many streams as you need, so that logging a message just once produces the same output in different places (i.e., a plain text file and a database table).

Additionally, you can configure each stream: for example, you might want all messages to be logged to the plain text file but only WARNING messages or above into the database.

As of version 2.2.0, Logga comes with 4 streams: FileStream, HttpStream, MailStream and StandardOutputStream (with several others currently in the works, such as DatabaseStream).

###Default streams If you don't specifically provide any stream to Logga's constructor, the library will use both a FileStream and a StandardOutputStream by default (the first one logging to a file named default_log.log).

###Creating a custom stream You can create a stream by instantiating any class which extends from LogStream, optionally passing an array with the desired options:

$s = new FileStream(array('file' => 'my_custom_log_file', 'date' => TRUE));
$l = new Logga($s);
$l->info('Hi, custom file!');

The above will produce a file called my_custom_log_file_<datetime>.log, where datetime is the current date and time.

You can use more than one stream. Just call Logga's constructor with an array of streams:

$s1 = new FileStream(array('file' => 'my_first_custom_log_file', 'date' => TRUE));
$s2 = new FileStream(array('file' => 'my_second_custom_log_file', 'date' => TRUE));
$l = new Logga(array($s1, $s2));
$l->info('Hi, custom file!');

##Streams ###Specifying a log level

###Enabling and disabling streams

###Available stream classes

##Formatters

carlosafonso/logga 适用场景与选型建议

carlosafonso/logga 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.03k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-13