定制 0x20h/monoconf 二次开发

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

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

0x20h/monoconf

最新稳定版本:0.1.1

Composer 安装命令:

composer require 0x20h/monoconf

包简介

log4j like logging configuration for the monolog framework

README 文档

README

Monoconf

log4j like configuration for the monolog logging framework.

Usage

  1. Create a config JSON file:
{
	"rules": {
        "*": {
            "error": {
                "handler": ["error-handler"]
            }
        },
		"MyApp\\Controller*": {
			"debug": {
                "handler": ["debug-handler"],
                "processor": ["pid"]
            },
            "error": {
                "handler": ["error-handler"]
            }
		}
	},
	"handler": {
		"error-handler": {
			"type": "Monolog\\Handler\\StreamHandler",
			"args": [
				"/my/app/error.log"
			],
			"formatter": "line"
		},
		"debug-handler": {
			"type": "Monolog\\Handler\\StreamHandler",
			"args": [
				"/my/app/application.log"
			],
			"formatter": "line"
		}
	},
    "formatter": {
        "line": {
			"type": "Monolog\\Formatter\\LineFormatter",
			"args": [
				"%datetime% %pid% %channel%@%level_name% %message% %context%\n"
			]
        }
	},
    "processor": {
        "pid": {
            "type": "Monolog\\Processor\\ProcessIdProcessor",
            "args": [
            ]
        }
    }
}
  1. In your application:
require 'vendor/autoload.php';

use Monoconf\Monoconf;

// initialize monoconf
Monoconf::config(json_decode(file_get_contents('monoconf.json'), true));
namespace MyApp\Controller;

class SomeController {

    protected $Log;

    public function __construct() {
        self::$Log = \Monoconf\Monoconf::getLogger(__CLASS__);
    }

    public function someAction()
    {
        self::$Log->debug(__METHOD__.' called');
    }
}

Using this setup every class in the MyApp\Controller namespace will get a logger that logs every message up to debug to /my/app/error.log and every other class will get a logger that logs messages up to error to /my/app/error.log.

Tests

phpunit --bootstrap tests/bootstrap.php tests/

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-06-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固