Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

Commit b33c367

Browse files
authored
Merge pull request #15 from Hexanet/better-doc
Better doc
2 parents ad2e0d3 + cdc7ab4 commit b33c367

File tree

2 files changed

+136
-30
lines changed

2 files changed

+136
-30
lines changed

README.md

+91-30
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,125 @@ Symfony2 bundle with extra processors and logger to log request/response.
66

77
## Installation
88

9-
```
9+
```bash
1010
composer require hexanet/monolog-extra-bundle
1111
```
1212

13-
## Configuration reference
13+
## Usage
14+
15+
### Processors
16+
17+
The bundle provides several processors:
18+
19+
* User
20+
* Session ID
21+
* UID
22+
* Additions
23+
24+
#### User
1425

26+
The *UserProcessor* add data about the current user in each log entry.
27+
28+
```yaml
29+
hexanet_monolog_extra:
30+
processor:
31+
user: true
1532
```
33+
34+
The default provider returns:
35+
* anonymous when no user is logged
36+
* the username of the current logged user
37+
* cli
38+
39+
You can create your own provider by creating a service that implements *Hexanet\Common\MonologExtraBundle\Provider\User\UserProviderInterface*.
40+
41+
```yaml
1642
hexanet_monolog_extra:
43+
provider:
44+
user: your_own_provider_service_id
45+
```
46+
47+
#### Session ID
1748
18-
# add data to extra in each records of log
49+
Add the session id in each log entry.
50+
51+
```yaml
52+
hexanet_monolog_extra:
1953
processor:
54+
session_id: true
55+
```
2056
21-
# add the username of the current user
22-
user: true
57+
You can create your own provider by creating a service that implements *Hexanet\Common\MonologExtraBundle\Provider\Session\SessionIdProviderInterface*.
2358
24-
# add the session id
25-
session_id: false
59+
```yaml
60+
hexanet_monolog_extra:
61+
provider:
62+
session_id: your_own_provider_service_id
63+
```
2664
27-
# add Unique Identification Number
28-
uid: true
65+
#### UID
2966
30-
# add symfony environnement
31-
environment: true
67+
Add an unique identifier for the request in each log entry.
3268
33-
# add static data
34-
additions:
35-
type: symfony
36-
application: symfony application
37-
extra_info: blabla
69+
```yaml
70+
hexanet_monolog_extra:
71+
processor:
72+
uid: true
73+
```
3874
39-
logger:
40-
# log each request
41-
on_request: true
75+
The bundle comes with 2 providers:
4276
43-
# log console exception
44-
on_console_exception: true
77+
* UniqidProvider (default): use `uniqid`
78+
* ApacheUniqueIdProvider: get from environment, need [*mod_unique_id*](https://httpd.apache.org/docs/2.4/mod/mod_unique_id.html) of Apache
4579

46-
# add uid in the headers of responses
47-
add_uid_to_response: true
80+
You can create your own provider by creating a service that implements *Hexanet\Common\MonologExtraBundle\Provider\Uid\UidProviderInterface*.
4881

49-
# you can change the provider for uid, user and session_id
82+
```yaml
83+
hexanet_monolog_extra:
5084
provider:
51-
uid: hexanet_monolog_extra.logger.provider.uid.apache_unique_id
85+
uid: your_own_provider_service_id
86+
```
87+
88+
#### Additions
5289

53-
user: hexanet_monolog_extra.logger.provider.user.symfony
90+
Add custom data in each log entry.
5491

55-
session_id: hexanet_monolog_extra.logger.provider.session.symfony
92+
```yaml
93+
hexanet_monolog_extra:
94+
additions:
95+
type: symfony
96+
application: the best symfony application
97+
locale: "%locale%"
98+
environment: "%kernel.environment%"
5699
```
57100

101+
### Loggers
102+
103+
#### On request
104+
105+
Create a log entry with the request data.
106+
107+
#### On response
108+
109+
Create a log entry with the response data.
58110

59-
### Apache Unique ID
111+
#### On console exception
60112

61-
This module add an unique id to each request.
113+
Create a log entry when an exception occurs in console.
114+
115+
#### Add UID to response
116+
117+
Add the UID of the previous processor in the response headers.
62118

63119
```
64-
a2enmod unique_id
120+
HTTP/1.1 302 Found
121+
X-UID: 57c5f5e842b10
65122
```
66123
124+
## Configuration reference
125+
126+
[Configuration reference](doc/configuration_reference.md) for a reference on the available configuration options.
127+
67128
## Credits
68129
69130
Developed by the [Web Team](https://teamweb.hexanet.fr/) of [Hexanet](http://www.hexanet.fr/).

doc/configuration_reference.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Configuration reference
2+
3+
```yaml
4+
hexanet_monolog_extra:
5+
6+
# add data to extra in each records of log
7+
processor:
8+
9+
# add the username of the current user
10+
user: true
11+
12+
# add the session id
13+
session_id: false
14+
15+
# add Unique Identification Number
16+
uid: true
17+
18+
# add static data
19+
additions:
20+
type: symfony
21+
application: symfony application
22+
extra_info: blabla
23+
environment: "%kernel.environment%"
24+
25+
logger:
26+
# log each request
27+
on_request: true
28+
29+
# log each response
30+
on_response: true
31+
32+
# log console exception
33+
on_console_exception: true
34+
35+
# add uid in the headers of responses
36+
add_uid_to_response: true
37+
38+
# you can change the provider for uid, user and session_id
39+
provider:
40+
uid: hexanet_monolog_extra.logger.provider.uid.apache_unique_id
41+
42+
user: hexanet_monolog_extra.logger.provider.user.symfony
43+
44+
session_id: hexanet_monolog_extra.logger.provider.session.symfony
45+
```

0 commit comments

Comments
 (0)