centagon/papertrail 问题修复 & 功能扩展

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

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

centagon/papertrail

Composer 安装命令:

composer require centagon/papertrail

包简介

Integrate Papertrail log monitor in your PHP applications

README 文档

README

Build Status

Easily integrate Papertrail log monitor in your PHP applications. This package provides integration for plain vanilla PHP and Laravel.

Installation

composer require centagon/papertrail

Configuration

It is good practice not to include credentials in your code so passwords are not stored in version control. Keeping sensitive info in your code could become an issue when you need to open source or share your code with other developers. For this reason, this package will get your papertrail log server details from environment variables PAPERTRAIL_HOST, PAPERTRAIL_PORT and PAPERTRAIL_HOSTNAME by default.

This package ships with 2 drivers:

  • Php for plain PHP applications
  • Laravel for Laravel applications from version 4.2 to 5.6

Plain Vanilla PHP

For plain PHP applications, we recommend also installing Monolog:

composer require monolog/monolog

then integrate the papertrail package like so:

require __DIR__ . '/vendor/autoload.php';

use StephaneCoinon\Papertrail\Php as Papertrail;

// Boot using default settings (ie Papertrail log server and port
// from environment variables and no log message prefix).
// It also gives you a monolog instance in the process.
$logger = Papertrail::boot();

// Now your logs will appear in Papertrail dashboard.
$logger->info('test log');

Laravel 4

Add these lines in your start/global.php:

// Pass all parameters
\StephaneCoinon\Papertrail\Laravel::boot($host, $port, $prefix);

or

// Grab log server details from environment variables and use a prefix
\StephaneCoinon\Papertrail\Laravel::bootWithPrefix('MY_APP');

Laravel 5

Edit app/Providers/AppServiceProvider.php and add this line in boot method:

\StephaneCoinon\Papertrail\Laravel::boot();

then test it's working:

// routes/web.php

Route::get('log', function () {
    Log::info('test log', ['foo' => 'bar']);

    return 'Logged';
});

API reference

All drivers provide the following interface:

/**
 * Boot connector with given host, port and log message prefix.
 * 
 * If host or port are omitted, we'll try to get them from the environment
 * variables PAPERTRAIL_HOST and PAPERTRAIL_PORT.
 * 
 * @param  string $host   Papertrail log server, ie log.papertrailapp.com
 * @param  int $port      Papertrail port number for log server
 * @param  string $prefix Prefix to use for each log message
 * @return \Psr\Log\LoggerInterface
 */
public static function boot($host = null, $port = null, $prefix = '')
/**
 * Boot connector using credentials set in environment variables and the
 * given log message prefix.
 * 
 * @param string $prefix Prefix to use for each log message
 * @return \Psr\Log\LoggerInterface
 */
public static function bootWithPrefix($prefix)

Tests

First, copy .env.dist as .env and set your Papertrail host, port and API key in it.

Then run PHPUnit:

./vendor/bin/phpunit

centagon/papertrail 适用场景与选型建议

centagon/papertrail 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.77k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 centagon/papertrail 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 centagon/papertrail 我们能提供哪些服务?
定制开发 / 二次开发

基于 centagon/papertrail 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-30