承接 linkorb/flex-log 相关项目开发

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

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

linkorb/flex-log

最新稳定版本:v1.0.1

Composer 安装命令:

composer require linkorb/flex-log

包简介

Simple wrapper around monolog-cascade adding practical utilities

README 文档

README

FlexLog: flexible configurable logging for your applications

Allows reconfiguring the handlers, processor and formatters of your application's loggers through environment variables and config files.

FlexLog is a very thin wrapper around the awesome monolog-cascade library.

It adds:

  • simple initialization based on the config file specified by the FLEX_LOG environment variable
  • ensures that all loggers your application expects are always added to Monolog's Registry, even if no cascade config file is used, or it misses a definition for that logger name.

Configuration

## Specify a cascade config file (yaml):
FLEX_LOG=/path/to/my/cascade.yaml

Usage

At the earliest entry point in your application (index.php, bootstap.php, etc), add the following line to initialize FlexLog:

use FlexLog\FlexLog;

FlexLog::initFromEnv()
FlexLog::ensureLoggers(['app', 'db', 'caching']); // ensures that loggers with these names exist and are registered

Then, from anywhere in your app, log to monolog as usual. For example by using Monolog's registry:

$username = 'joe';
\Monolog\Registry::app()->info("User {username} logged in", ['username' => $username]);

A fully working example can be found in the test cases in tests/

Tests

./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/

Links

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-26