定制 linio/microlog 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

linio/microlog

最新稳定版本:3.0.0

Composer 安装命令:

composer require linio/microlog

包简介

Provides a static wrapper around monolog

README 文档

README

Microlog - Static wrapper around Monolog

Purpose

Logging is a part of all applications. Having to inject in a logging service requires a dependency that has nothing to do with the code that you are writing. Microlog was created to remove this requirement.

Microlog allows you create log entries in different contexts from any part of your application. Microlog is built with never throwing exceptions in mind. An exception caused by logging causes the normal flow of your application to fail, and logging shouldn't do that.

Installation

To install microlog:

$ composer require linio/microlog

Basic Usage

<?php

declare(strict_types=1);

use Linio\Component\Microlog\Log;
use Monolog\Handler\StreamHandler;

// Register a logger for a channel
$defaultLogger = new StreamHandler();
Log::setLoggerForChannel($defaultLogger, Log::DEFAULT_CHANNEL);

// Log an emergency
Log::emergency('This is a test emergency');

// Log an alert
Log::alert('This is a test alert');

// Log a critical error
Log::critical('This is a test critical error');

// Log an error
Log::error('This is a test error');

// Log a warning
Log::warning('This is a test warning');

// Log a notice
Log::notice('This is a test notice');

// Log a bit of information
Log::info('This is test information');

// Log debug information
Log::debug('This is test debug information');

// Log at an arbitrary level
Log::log('emergency', 'This is a test entry at an arbitrary level of emergency');

Multiple Channels

Channels allow you to configure different handlers for different types of messages.

By default, all logs will be created in the default logging channel Log::DEFAULT_CHANNEL (default). If you wish to specify a different channel when logging, the second parameter to all non-arbitrary level log methods.

<?php

declare(strict_types=1);

use Linio\Component\Microlog\Log;
use Monolog\Handler\StreamHandler;

$defaultLogger = new NullLogger();
Log::setLoggerForChannel($defaultLogger, 'emergency');

Log::emergency('This is an emergency in the emergency channel', 'emergency');

Contributing

Feel free to send your contributions as a PR. Make sure you update/write new tests to support your contribution. Please follow PSR-2.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-05-10