Skip to content

Commit 0c947a4

Browse files
author
arashdalir
committed
composer packaging corrected
1 parent b10c661 commit 0c947a4

File tree

12 files changed

+631
-220
lines changed

12 files changed

+631
-220
lines changed

README.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
# Psr3Log
1+
# PHP-Psr3Log
22

3-
`ArashDalir/Psr3Log` is a [PSR3](http://www.php-fig.org/psr/psr-3/) implementation,
3+
`ArashDalir\Psr3Log` is a [PSR3](http://www.php-fig.org/psr/psr-3/) implementation,
44
which sending log according [RFC 5424](https://tools.ietf.org/html/rfc5424).
55
This library forks the implementation of UDP-Based SysLog library implemented as [lvht\updlog](https://github.com/lvht/udplog), generalises it and allows further extension of the base system.
66

77
## Install
88

99
Use following command to add the repository to your project:
1010

11-
composer require ArashDalir/SysLog:dev-master
11+
composer require arashdalir/php-psr3log:dev-master
12+
1213

1314
Or add following line to your composer.json:
1415

1516
```json
1617
{
1718
"require": {
18-
"arashdalir/psr3log": "dev-master"
19+
"arashdalir/php-psr3log": "dev-master"
1920
}
2021
}
2122
```
@@ -24,20 +25,38 @@ Currently, there is only one realization of Psr3Log Handlers for SysLog over UDP
2425

2526

2627
### Usage on Windows:
27-
Please note that on Windows [only LOG_USER facility is allowed](http://php.net/manual/en/function.openlog.php). Using other facilities will throw an Exception of type `ArashDalir\Handler\SysLog\InvalidFacilityException`.
28+
Please note that on Windows [only LOG_USER facility is allowed](http://php.net/manual/en/function.openlog.php). 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.
29+
30+
### Local SysLog:
31+
but not defining an address when creating an object, the object tries to write the values in local syslog.
32+
2833
```php
2934
<?php
30-
$log = new ArashDalir\Handler\SysLog\SysLog('ip addr', 'port');
31-
$log->facility(LOG_KERN)
32-
->hostname('foo.com')
33-
->procid(8848)
34-
->msgid('demo')
35-
->appname('php');
36-
37-
$log->error('UDP SysLog Error Test');
38-
$log->info('UDP SysLog Info Test');
39-
$log->debug('UDP SysLog Debug Test');
40-
$log->emergency('UDP SysLog Emergency Test');
35+
include 'vendor/autoload.php';
36+
37+
$udp = new ArashDalir\Handler\SysLog\SysLog('127.0.0.1');
38+
$udp->getLogMessage()->setFacility(LOG_AUTH, false)
39+
->setHostname('ada.gemik')
40+
->setProcessId(8848)
41+
->setMessageId('demo')
42+
->setAppName('php');
43+
44+
$udp->error('UDP SysLog Error Test');
45+
$udp->info('UDP SysLog Info Test');
46+
$udp->debug('UDP SysLog Debug Test');
47+
$udp->emergency('UDP SysLog Emergency Test');
48+
49+
$local = new \ArashDalir\Handler\SysLog\SysLog();
50+
$local->getLogMessage()->setFacility(LOG_USER)
51+
->setHostname('ada.gemik')
52+
->setProcessId(8848)
53+
->setMessageId('demo')
54+
->setAppName('php');
55+
56+
$local->error('Local SysLog Error Test');
57+
$local->info('Local SysLog Info Test');
58+
$local->debug('Local SysLog Debug Test');
59+
$local->emergency('Local SysLog Emergency Test');
4160
```
4261

4362
## Status

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "arashdalir/psr3log",
2+
"name": "arashdalir/php-psr3log",
33
"authors": [
44
{
55
"name": "Arash Dalir",
@@ -8,11 +8,11 @@
88
],
99
"autoload": {
1010
"psr-4": {
11-
"arashdalir\\": "./src"
11+
"ArashDalir\\": "./src"
1212
}
1313
},
1414
"provide": {
15-
"psr/log-implementation": "2.0.0"
15+
"psr/log-implementation": "1.0.0"
1616
},
1717
"require": {
1818
"php": "^5.6",

demo.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
<?php
22
include 'vendor/autoload.php';
33

4-
$log = new arashdalir\Handler\SysLog\SysLog('127.0.0.1');
5-
$log->facility(LOG_KERN)
6-
->hostname('yourname.com')
7-
->procid(8848)
8-
->msgid('demo')
9-
->appname('php');
10-
11-
$log->error('UDP SysLog Error Test');
12-
$log->info('UDP SysLog Info Test');
13-
$log->debug('UDP SysLog Debug Test');
14-
$log->emergency('UDP SysLog Emergency Test');
4+
$udp = new ArashDalir\Handler\SysLog\SysLog('127.0.0.1');
5+
$udp->getLogMessage()->setFacility(LOG_AUTH, false)
6+
->setHostname('ada.gemik')
7+
->setProcessId(8848)
8+
->setMessageId('demo')
9+
->setAppName('php');
10+
11+
$udp->error('UDP SysLog Error Test');
12+
$udp->info('UDP SysLog Info Test');
13+
$udp->debug('UDP SysLog Debug Test');
14+
$udp->emergency('UDP SysLog Emergency Test');
15+
16+
$local = new \ArashDalir\Handler\SysLog\SysLog();
17+
$local->getLogMessage()->setFacility(LOG_USER)
18+
->setHostname('ada.gemik')
19+
->setProcessId(8848)
20+
->setMessageId('demo')
21+
->setAppName('php');
22+
23+
$local->error('Local SysLog Error Test');
24+
$local->info('Local SysLog Info Test');
25+
$local->debug('Local SysLog Debug Test');
26+
$local->emergency('Local SysLog Emergency Test');

src/Foundation/ILog.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
namespace ArashDalir\Foundation;
1010

1111
interface ILog{
12+
/**
13+
* @param LogMessage $message
14+
*
15+
* @return mixed
16+
*/
1217
function send($message);
13-
function prepareContext($context);
14-
function prepareTimestamp($timestamp);
15-
function prepareLevel($level);
16-
function prepareLogExtra();
1718
}

src/Foundation/ILogMessage.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: ada
5+
* Date: 12-Jun-18
6+
* Time: 11:37
7+
*/
8+
9+
namespace ArashDalir\Foundation;
10+
11+
interface ILogMessage{
12+
function asString($property);
13+
function __toString();
14+
}

0 commit comments

Comments
 (0)