projek-xyz/slim-monolog 问题修复 & 功能扩展

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

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

projek-xyz/slim-monolog

最新稳定版本:v0.1.6

Composer 安装命令:

composer require projek-xyz/slim-monolog

包简介

Write log file on your Slim 3 application with Monolog logger.

README 文档

README

LICENSE VERSION Build Status Coveralls Code Climate Code Climate SensioLabs Insight

Write log file on your Slim 3 application with Monolog logger.

Install

Via Composer

$ composer require projek-xyz/slim-monolog --prefer-dist

Requires Slim micro framework 3 and PHP 5.5.0 or newer.

Usage

// Create Slim app
$app = new \Slim\App();

// Fetch DI Container
$container = $app->getContainer();

// Register Monolog helper:
// Option 1, using MonologProvider
$container->register(new \Projek\Slim\MonologProvider);

// Option 2, using Closure
$container['logger'] = function ($c) {
    $settings = [
        // Path to log directory
        'directory' => 'path/to/logs',
        // Log file name
        'filename' => 'my-app.log',
        // Your timezone
        'timezone' => 'Asia/Jakarta',
        // Log level
        'level' => 'debug',
        // List of Monolog Handlers you wanna use
        'handlers' => [],
    ];

    return new \Projek\Slim\Monolog('slim-app', $settings);
};

// Define a log middleware
$app->add(function ($req, $res, $next) {
    $return = $next($req, $res);

    $this->logger->info('Something happen');

    return $return;
});

// Run app
$app->run();

NOTE:

  • If you are using option 1 please make sure you already have $container['settings']['logger'] in your configuration file.
  • $settings['filename'] only required if you have $settings['directory']
  • Set $settings['directory'] to syslog to use System Log.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

License

This library is open-sourced software licensed under MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-05