Giter Club home page Giter Club logo

php-psr3log's Introduction

PHP-Psr3Log

ArashDalir\Psr3Log is a PSR3 implementation, which sending log according RFC 5424. This library forks the implementation of UDP-Based SysLog library implemented as lvht\updlog, generalises it and allows further extension of the base system.

Install

Use following command to add the repository to your project:

composer require arashdalir/php-psr3log:dev-master

Or add following line to your composer.json:

{
  "require": {
     "arashdalir/php-psr3log": "dev-master"
  }
}

Usage

Currently, there is only one realization of Psr3Log Handlers for SysLog over UDP format and local SysLog.

Local SysLog:

By not defining an address when creating an object, the object tries to write the values in local syslog.

UDP-Based SysLog Client:

The constructor function accepts an IP-Address and a port where the syslog server is, and will send logs to the remote server.

Usage on Windows:

Please note that on Windows only LOG_USER facility is allowed. Using other facilities will throw an Exception of type ArashDalir\Handler\SysLog\InvalidFacilityException, if the second parameter for setFacility($facility, $os_form) is set to true.

<?php
include 'vendor/autoload.php';

$udp = new ArashDalir\Handler\SysLog\SysLog('127.0.0.1');
$udp->getLogMessage()->setFacility(LOG_AUTH, false)
    ->setVersion(\ArashDalir\Handler\SysLog\SysLogMessage::VERSION_1) // available as of V1.1.0
    ->setHostname('ada')
    ->setProcessId(8848)
    ->setMessageId('demo')
    ->setAppName('php');

$udp->error('UDP SysLog Error Test');
$udp->info('UDP SysLog Info Test');
$udp->debug('UDP SysLog Debug Test');
$udp->emergency('UDP SysLog Emergency Test');

$local = new \ArashDalir\Handler\SysLog\SysLog();
$local->getLogMessage()->setFacility(LOG_USER)
    ->setHostname('ada')
    ->setProcessId(8848)
    ->setMessageId('demo')
    ->setAppName('php');

$local->error('Local SysLog Error Test');
$local->info('Local SysLog Info Test');
$local->debug('Local SysLog Debug Test');
$local->emergency('Local SysLog Emergency Test');

Status

Psr3Log extends Udplog. It provides a PSR-3 conform implementation of a logger. As Udplog, Psr3Log doesn't support STRUCTURED-DATA. Hopefully the future releases will cover this up...

Versions

v1.1.0:

  • added support for RFC5424 (syslog V1)
  • message timestamp can be set manually if psr3log->log function is used directly - mainly implemented for extension purposes, so that log messages from other loggers can be fed into this library.

v1.0.0:

first stable release - following features implemented

php-psr3log's People

Contributors

taoso avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.