oz-sysb/fluent-logger

fluent-log ライブラリ

v1.0.4 2024-04-25 07:56 UTC

This package is auto-updated.

Last update: 2024-10-25 08:56:13 UTC


README

Build Status Coverage Status Total Downloads Packagist License

Requirements

  • PHP 5.3 or higher

Installation

Library is available on Packagist.

It's recommended that you use Composer to install oz-sysb/fluent-logger.

$ composer require oz-sysb/fluent-logger

Usage

PHP side

<?php

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

use \Fluent\Logger\FluentLogger as Client;
use \OzSysb\Logger\OzLogger;

// Always define first
OzLogger::setApplication('woodstock');
// init class.
$logger = new OzLogger(new Client('unix:///var/run/td-agent/td-agent.sock'));

// ... snip ...

// Describe every required part

$type = 'api-client';
$logger->info($type, 'Post to https://example.com/api/member, and post params id=100&key=value', __FUNCTION__, __CLASS__);
$logger->info($type, 'Response from https://example.com/api/member response body is {"status": "successed!"}', __FUNCTION__, __CLASS__);


// ... snip ...
$type = 'db';
$logger->info($type, "DB Insert : inserts member_id=100 to super1 table", __FUNCTION__, __CLASS__);
$type = 'db';
$logger->error($type, "DB Error : ERROR 1099 (HY000): Table 'super1' was locked with a READ lock and can't be updted", __FUNCTION__, __CLASS__);

Fluentd side

Use in_forward.

<source>
  @type forward
</source>

License

MIT