Skip to content

Commit a5260b9

Browse files
committed
Improve README
1 parent a03f877 commit a5260b9

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,55 @@
22

33
PHP logger for all Buffer services
44

5-
## Requirements:
65

7-
- 1 - Install composer by following [those steps](https://getcomposer.org/download/)
8-
- 2 (optional) - `mv composer.phar /usr/local/bin/composer`
6+
## Requirements
97

8+
PHP 7.1 and later.
9+
10+
## Setup BuffLog in your PHP project via Composer
11+
12+
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command:
13+
14+
```bash
15+
composer require bufferapp/php-bufflog
16+
```
17+
18+
19+
## Usage
20+
As simple as...
21+
22+
```php
23+
use Buffer\Bufflog;
24+
25+
Bufflog::debug("I am a debug");
26+
Bufflog::info("I am an info");
27+
Bufflog::warn("I am a warning");
28+
Bufflog::error("I am an error");
29+
Bufflog::critical("I am a warning");
30+
```
31+
32+
If you wish add more context in your logs,
33+
```php
34+
Bufflog::debug("some context", ["my key" => " my value"]);
35+
Bufflog::info("I am a info with context", ["my key" => " my value"]);
36+
Bufflog::warn("I am a warning", ["duration" => "40ms"]);
37+
38+
Bufflog::critical("I'm critical log, here some extra fancy informations",
39+
[
40+
"duration" => "40ms",
41+
"services_related" => [
42+
"Twitter",
43+
"Facebook",
44+
"Instagram"
45+
]
46+
]
47+
);
48+
49+
```
1050

1151
## Install the project
1252

1353
```
14-
# This will install all the dependencies
54+
# This will install all the dependencies this project needs
1555
composer install
1656
```

example.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Bufflog::debug("I am a debug with context", ["my key" => " my value"]);
88

99
Bufflog::info("I am an info");
10-
Bufflog::debug("I am a info with context", ["my key" => " my value"]);
10+
Bufflog::info("I am a info with context", ["my key" => " my value"]);
1111

1212
Bufflog::warn("I am a warning");
1313
Bufflog::warn("I am a warning", ["duration" => "40ms"]);
@@ -17,3 +17,14 @@
1717

1818
Bufflog::critical("I am critical information!");
1919
Bufflog::critical("I am critical information!", ["user" => "betrand"]);
20+
21+
Bufflog::critical("I'm critical log, here some extra fancy informations",
22+
[
23+
"duration" => "40ms",
24+
"services_related" => [
25+
"Twitter",
26+
"Facebook",
27+
"Instagram"
28+
]
29+
]
30+
);

src/php-bufflog/BuffLog.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,34 @@ class BuffLog {
2222

2323
private static $logger = null;
2424

25-
public static function debug($message)
25+
public static function debug($message, $context = [], $extra = [])
2626
{
27-
$logOutput = self::formatLog($message, Logger::DEBUG, $context = [], $extra = []);
27+
$logOutput = self::formatLog($message, Logger::DEBUG, $context, $extra);
2828
self::getLogger()->debug($logOutput);
2929
}
3030

31-
public static function info($message)
31+
public static function info($message, $context = [], $extra = [])
3232
{
33-
$logOutput = self::formatLog($message, Logger::INFO, $context = [], $extra = []);
33+
$logOutput = self::formatLog($message, Logger::INFO, $context, $extra);
3434
self::getLogger()->info($logOutput);
3535
}
3636

37-
public static function warn($message)
37+
public static function warn($message, $context = [], $extra = [])
3838
{
39-
$logOutput = self::formatLog($message, Logger::WARNING, $context = [], $extra = []);
39+
$logOutput = self::formatLog($message, Logger::WARNING, $context, $extra);
4040
self::getLogger()->warn($logOutput);
4141
}
4242

43-
public static function error($message)
43+
public static function error($message, $context = [], $extra = [])
4444
{
45-
$logOutput = self::formatLog($message, Logger::ERROR, $context = [], $extra = []);
45+
$logOutput = self::formatLog($message, Logger::ERROR, $context, $extra);
4646
self::getLogger()->error($logOutput);
4747
}
4848

4949
// @TODO: That one might could also create an alert in Datadog?
50-
public static function critical($message)
50+
public static function critical($message, $context = [], $extra = [])
5151
{
52-
$logOutput = self::formatLog($message, Logger::CRITICAL, $context = [], $extra = []);
52+
$logOutput = self::formatLog($message, Logger::CRITICAL, $context, $extra);
5353
self::getLogger()->critical($logOutput);
5454
}
5555

0 commit comments

Comments
 (0)