承接 geoffroy-aubry/logger 相关项目开发

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

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

geoffroy-aubry/logger

Composer 安装命令:

composer require geoffroy-aubry/logger

包简介

PSR-3 logger for adding colors and indentation on PHP CLI output.

README 文档

README

Latest stable version Build Status Coverage Status

PSR-3 logger for adding colors and indentation on PHP CLI output.

Description

Use tags and placeholder syntax to provide an easy way to color and indent PHP CLI output. PSR-3 compatibility allows graceful degradation when switching to another PSR-3 compliant logger.

Colors

  1. Declare some colors:
    $aConfig = array(
        'colors' => array(
            'debug'      => "\033[0;35m",
            'error'      => "\033[1;31m",
            'section'    => "\033[1;37m",
            'subsection' => "\033[1;33m",
            'ok'         => "\033[1;32m"
        )
    );
    $oLogger = new ColoredIndentedLogger($aConfig);
  1. Use them either by exploiting placeholder syntax with 'C.' prefix:
    $oLogger->info('{C.section}Start of new section');
    $oLogger->info('Result is {C.ok}OK');

Or by logging message with a level equals to a color key:

    $oLogger->debug('some debug information…');
    $oLogger->error(new \RuntimeException('Arghhhh!'));

It is even possible to specify color tag in the value of a placeholder:

    $oLogger->info('Result is {result}', array('result' => '{C.ok}OK'));

See below for demonstration.

Indentation

You can control indentation level with indent and unindent tags:

  • default tags are '+++' and '---',
  • both usable at the beginning or at the end of any message,
  • one or more occurrences,
  • can be used alone.

Example:

$oLogger->info('Section A+++');
$oLogger->info('Subsection+++');
$oLogger->info('Step 1');
$oLogger->info('Step 2');
$oLogger->info('------Section B+++');

See below for demonstration.

Configuration

Default configuration:

array(
    'colors'               => array(),
    'base_indentation'     => "\033[0;30m┆\033[0m   ",
    'indent_tag'           => '+++',
    'unindent_tag'         => '---',
    'min_message_level'    => \Psr\Log\LogLevel::DEBUG,
    'reset_color_sequence' => "\033[0m",
    'color_tag_prefix'     => 'C.'
);

Where:

  • colors(array) Array of key/value pairs to associate bash color codes to color tags (see above).
  • base_indentation(string) Describe what is a simple indentation, e.g. "\t".
  • indent_tag(string) Tag usable at the start or at the end of the message to add one or more indentation level.
  • unindent_tag(string) Tag usable at the start or at the end of the message to remove one or more indentation level.
  • min_message_level(string) Threshold required to log message, must be defined in \Psr\Log\LogLevel.
  • reset_color_sequence(string) Concatenated sequence at the end of message when colors are used. For example: "\033[0m".
  • color_tag_prefix(string) Prefix used in placeholders to distinguish standard context from colors.

Demo

See demo.php script for an example:

$ php examples/demo.php

Here is the result:

result of demo.php

Usage

  1. Class autoloading and dependencies are managed by Composer so install it following the instructions on Composer: Installation - *nix or just run the following command:
$ curl -sS https://getcomposer.org/installer | php
  1. Add dependency to GAubry\Logger into require section of your composer.json:
    {
        "require": {
            "geoffroy-aubry/logger": "1.*"
        }
    }

and run php composer.phar install from the terminal into the root folder of your project.

  1. Include Composer's autoloader and use the GAubry\Logger class:
    <?php
    
    require_once 'vendor/autoload.php';
    use GAubry\Logger\ColoredIndentedLogger;
    
    $aConfig = array(…);
    $oLogger = new ColoredIndentedLogger($aConfig);
    
    $oLogger->info('Hello');
    …

Documentation

API documentation generated by ApiGen and included in the doc/api folder.

Copyrights & licensing

Licensed under the GNU Lesser General Public License v3 (LGPL version 3). See LICENSE file for details.

Change log

See CHANGELOG file for details.

Continuous integration

Build Status Coverage Status

Following commands are executed during each build and must report neither errors nor warnings:

  • Unit tests with PHPUnit:

    $ php vendor/bin/phpunit --configuration phpunit.xml
  • Coding standards with PHP CodeSniffer:

    $ php vendor/bin/phpcs --standard=PSR2 src/ tests/ -v
  • Code quality with PHP Mess Detector:

    $ php vendor/bin/phpmd src/ text codesize,design,unusedcode,naming,controversial

Git branching model

The git branching model used for development is the one described and assisted by twgit tool: https://github.com/Twenga/twgit.

geoffroy-aubry/logger 适用场景与选型建议

geoffroy-aubry/logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.36k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2013 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 geoffroy-aubry/logger 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 21.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 36
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2013-06-06