承接 rebing/timber-laravel 相关项目开发

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

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

rebing/timber-laravel

Composer 安装命令:

composer require rebing/timber-laravel

包简介

Laravel package for communicating with Timber (timber.io) logger API

README 文档

README

Latest Version on Packagist Total Downloads Build Status

A Laravel 5+ wrapper for the Timber Logger service. Use it to log HTTP requests or custom events to Timber.

Installation

1. Require the package via Composer

$ composer require rebing/timber-laravel

2. Laravel 5.5+ will autodiscover the package, for older versions add the following service provider

Rebing\Timber\TimberServiceProvider::class,

and alias

'Timber' => 'Rebing\Timber\Support\Facades\Timber',

in your config/app.php file.

3. Publish the configuration file

$ php artisan vendor:publish --provider="Rebing\Timber\TimberServiceProvider"

4. Review the configuration file

config/timber.php

and add your Timber API key to .env

5. (Optional) Log incoming requests

Check HTTP Requests

6. (Optional) Log all messages

Check Log all messages

Usage

HTTP Requests

To log HTTP requests use the Rebing\Timber\Middleware\LogRequest::class middleware. This will log all incoming requests and responses, including context and Auth data.

For example, you can add it to Kernel.php:

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     */
    protected $middleware = [
        Rebing\Timber\Middleware\LogRequest::class,
    ];
}

Log all messages

This requires Laravel 5.6+

You can leverage Laravel's Logger facade to log all messages to Timber.

Add a new channel to config/logging.php

'channels' => [
    'timber' => [
        'driver' => 'monolog',
        'handler' => Rebing\Timber\Handlers\TimberHandler::class,
    ],
];

And update your .env with LOG_CHANNEL=timber

You can then easily log custom data by providing a message, type and data. For example:

$data = [
    'key' => 'value',
];
\Log::info('Some message', ['type' => $data]);

Custom Events

You can also log custom data. Context will be added automatically.

use Rebing\Timber\Requests\Events\CustomEvent;

$data = [
    'some' => 'data',
];

$customEvent = new CustomEvent('Log message', 'custom', $data);
dispatch($customEvent);
// Or $customEvent->send();

Disable logging

You can disable sending logs to Timber by updating your .env file with

TIMBER_ENABLED=false

Testing

$ phpunit

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email mikk.nurges@rebing.ee instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固