项目作者: keboola

项目描述 :
A simple library GELF server written in PHP
高级语言: PHP
项目地址: git://github.com/keboola/gelf-server.git
创建时间: 2016-05-17T12:54:11Z
项目社区:https://github.com/keboola/gelf-server

开源协议:

下载


GELF server GitHub Actions

A php implementation of a gelf compatible backend like Graylog2. This library provides
a simple server to which a GELF client can connect.

Installation

Recommended installation via composer:

Add gelf-server to composer.json either by running composer require keboola/gelf-server or by defining it manually:

  1. "require": {
  2. // ...
  3. "keboola/gelf-server": "^1.1"
  4. // ...
  5. }

Reinstall dependencies: composer install

Usage

To create a server, use the ServerFactory class:

  1. $server = ServerFactory::createServer(ServerFactory::SERVER_TCP);

To start listening for connections, us the start method. This method has the following parameters:

  • $minPort and $maxPort - to set port on which the server listens. To listen on a single port use the same value for
    both $minPort and $maxPort. Otherwise the server will randomly choose a free port in the specified range (inclusive).
  • $onStart - Callback executed when the server successfully started listening, the callback signature is function ($port), which
    gives you the actual port the server is listening on.
  • $onProcess - Callback executed periodically when the server is running. The callback has signature function (&$terminated).
    The server will keep running indefinitely until you set $terminated to true in this callback.
  • $onEvent - Callback executed when a GELF event is received. The callback has signature function ($event). The
    $event variable contains associative array with GELF fields
  • $onTerminate - Optional callback executed when the server terminates - after it stops listening for connections. The callback
    signature is function ().

Examples

For usage examples, see the /examples directory.

License

MIT licensed, see LICENSE file.