Skip to content

Commit 6e4db08

Browse files
committed
formatted
1 parent 9a65b85 commit 6e4db08

39 files changed

+412
-393
lines changed

.codeclimate.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ engines:
44
enabled: true
55
config:
66
languages:
7-
- javascript
8-
- php
7+
- javascript
8+
- php
99
eslint:
1010
enabled: true
1111
fixme:
@@ -23,8 +23,8 @@ engines:
2323
enabled: false
2424
ratings:
2525
paths:
26-
- "**.js"
27-
- "**.php"
26+
- "**.js"
27+
- "**.php"
2828
exclude_paths:
2929
- tests/
3030
- build/

.scrutinizer.yml

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
filter:
2-
excluded_paths: [tests/*]
2+
excluded_paths: [tests/*]
33

44
checks:
5-
php:
6-
code_rating: true
7-
remove_extra_empty_lines: true
8-
remove_php_closing_tag: true
9-
remove_trailing_whitespace: true
10-
fix_use_statements:
11-
remove_unused: true
12-
preserve_multiple: false
13-
preserve_blanklines: true
14-
fix_php_opening_tag: true
15-
fix_linefeed: true
16-
fix_line_ending: true
17-
fix_identation_4spaces: true
18-
fix_doc_comments: true
5+
php:
6+
code_rating: true
7+
remove_extra_empty_lines: true
8+
remove_php_closing_tag: true
9+
remove_trailing_whitespace: true
10+
fix_use_statements:
11+
remove_unused: true
12+
preserve_multiple: false
13+
preserve_blanklines: true
14+
fix_php_opening_tag: true
15+
fix_linefeed: true
16+
fix_line_ending: true
17+
fix_identation_4spaces: true
18+
fix_doc_comments: true

composer.json

+45-38
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
{
2-
"name": "phoole/logger",
3-
"type": "library",
4-
"license": "Apache-2.0",
5-
"version": "1.0.3",
6-
"description": "Simple & slim PSR-3 logger for PHP",
7-
"keywords": ["phoole", "library", "php", "logger", "psr-3", "swoole"],
8-
"authors": [
9-
{
10-
"name": "Hong Zhang",
11-
"homepage": "https://github.com/phoole"
12-
}
13-
],
14-
"require": {
15-
"php": ">=7.2.0",
16-
"phoole/base": "^1.0.20",
17-
"psr/log": "^1.0.1"
18-
},
19-
"require-dev": {
20-
"phpunit/phpunit": "^8"
21-
},
22-
"autoload": {
23-
"psr-4": {
24-
"Phoole\\Logger\\": "src/"
25-
}
26-
},
27-
"autoload-dev": {
28-
"psr-4": {
29-
"Phoole\\Tests\\": "tests/"
30-
}
31-
},
32-
"provide": {
33-
"psr/log-implementation": "1.0.0"
34-
},
35-
"minimum-stability": "dev",
36-
"scripts": {
37-
"test": "phpunit",
38-
"check": "phpcs --standard=psr12 src/",
39-
"format": "phpcbf --standard=psr12 src/"
2+
"name": "phoole/logger",
3+
"type": "library",
4+
"license": "Apache-2.0",
5+
"version": "1.0.5",
6+
"description": "Simple & slim PSR-3 logger for PHP",
7+
"keywords": [
8+
"phoole",
9+
"library",
10+
"php",
11+
"logger",
12+
"psr-3",
13+
"swoole"
14+
],
15+
"authors": [
16+
{
17+
"name": "Hong Zhang",
18+
"homepage": "https://github.com/phoole"
4019
}
20+
],
21+
"require": {
22+
"php": ">=7.2.0",
23+
"phoole/base": "^1.0.20",
24+
"psr/log": "^1.0.1"
25+
},
26+
"require-dev": {
27+
"phpunit/phpunit": "^8"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"Phoole\\Logger\\": "src/"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"Phoole\\Tests\\": "tests/"
37+
}
38+
},
39+
"provide": {
40+
"psr/log-implementation": "1.0.0"
41+
},
42+
"minimum-stability": "dev",
43+
"scripts": {
44+
"test": "phpunit",
45+
"check": "phpcs --standard=psr12 src/",
46+
"format": "phpcbf --standard=psr12 src/"
47+
}
4148
}

src/Entry/LogEntry.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getLevel(): string
7474
/**
7575
* {@inheritDoc}
7676
*/
77-
public function setLevel(string $level): LogEntryInterface
77+
public function setLevel(string $level)
7878
{
7979
if (!isset($this->convert[$level])) {
8080
throw new InvalidArgumentException("unknown log level");
@@ -130,9 +130,9 @@ public function getContext(): array
130130
/**
131131
* {@inheritDoc}
132132
*/
133-
public function setContext(array $context): LogEntryInterface
133+
public function setContext(array $context)
134134
{
135135
$this->context = $context;
136136
return $this;
137137
}
138-
}
138+
}

src/Entry/LogEntryInterface.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ public function getContext(): array;
4343

4444
/**
4545
* @param string $level
46-
* @return LogEntryInterface $this
46+
* @return $this
4747
* @throws InvalidArgumentException
4848
*/
49-
public function setLevel(string $level): LogEntryInterface;
49+
public function setLevel(string $level);
5050

5151
/**
5252
* Set context
5353
*
5454
* @param array $context
55-
* @return LogEntryInterface $this
55+
* @return $this
5656
*/
57-
public function setContext(array $context): LogEntryInterface;
57+
public function setContext(array $context);
5858

5959
/**
6060
* array of processor classname
@@ -67,4 +67,4 @@ public function getProcessors(): array;
6767
* @return string
6868
*/
6969
public function __toString(): string;
70-
}
70+
}

src/Entry/LogLevelTrait.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ trait LogLevelTrait
2424
* @var array
2525
*/
2626
protected $convert = [
27-
LogLevel::DEBUG => 100,
28-
LogLevel::INFO => 200,
29-
LogLevel::NOTICE => 300,
30-
LogLevel::WARNING => 400,
31-
LogLevel::ERROR => 500,
32-
LogLevel::CRITICAL => 600,
33-
LogLevel::ALERT => 700,
27+
LogLevel::DEBUG => 100,
28+
LogLevel::INFO => 200,
29+
LogLevel::NOTICE => 300,
30+
LogLevel::WARNING => 400,
31+
LogLevel::ERROR => 500,
32+
LogLevel::CRITICAL => 600,
33+
LogLevel::ALERT => 700,
3434
LogLevel::EMERGENCY => 800
3535
];
36-
}
36+
}

src/Entry/SystemLog.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public function getProcessors(): array
4545
parent::getProcessors(), [MemoryProcessor::class]
4646
);
4747
}
48-
}
48+
}

src/Formatter/AnsiFormatter.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ class AnsiFormatter extends DefaultFormatter
7070
* @access protected
7171
*/
7272
protected $colors = array(
73-
LogLevel::DEBUG => [self::FGCOLOR_GRAY, '', ''],
74-
LogLevel::INFO => ['', '', ''],
75-
LogLevel::NOTICE => [self::FGCOLOR_BRIGHT_GREEN, '', ''],
76-
LogLevel::WARNING => [self::FGCOLOR_BRIGHT_YELLOW, '', ''],
77-
LogLevel::ERROR => [self::FGCOLOR_BRIGHT_RED, '', ''],
78-
LogLevel::CRITICAL => [self::FGCOLOR_BRIGHT_RED, '', self::DECO_UNDERLINE],
79-
LogLevel::ALERT => [self::FGCOLOR_BRIGHT_RED, self::BGCOLOR_WHITE, ''],
73+
LogLevel::DEBUG => [self::FGCOLOR_GRAY, '', ''],
74+
LogLevel::INFO => ['', '', ''],
75+
LogLevel::NOTICE => [self::FGCOLOR_BRIGHT_GREEN, '', ''],
76+
LogLevel::WARNING => [self::FGCOLOR_BRIGHT_YELLOW, '', ''],
77+
LogLevel::ERROR => [self::FGCOLOR_BRIGHT_RED, '', ''],
78+
LogLevel::CRITICAL => [self::FGCOLOR_BRIGHT_RED, '', self::DECO_UNDERLINE],
79+
LogLevel::ALERT => [self::FGCOLOR_BRIGHT_RED, self::BGCOLOR_WHITE, ''],
8080
LogLevel::EMERGENCY => [self::FGCOLOR_BRIGHT_RED, self::BGCOLOR_WHITE, self::DECO_BLINK],
8181
);
8282

@@ -103,4 +103,4 @@ protected function addColor(string $level, string $text): string
103103
$suffix = $prefix ? self::DECO_END : '';
104104
return $prefix . $text . $suffix;
105105
}
106-
}
106+
}

src/Formatter/DefaultFormatter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ protected function getEol(): string
4747
return "\n";
4848
}
4949
}
50-
}
50+
}

src/Formatter/FormatterAwareInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public function setFormatter(FormatterInterface $formatter);
2828
* @return FormatterInterface
2929
*/
3030
public function getFormatter(): FormatterInterface;
31-
}
31+
}

src/Formatter/FormatterAwareTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ public function setFormatter(FormatterInterface $formatter)
3939
{
4040
$this->formatter = $formatter;
4141
}
42-
}
42+
}

src/Formatter/FormatterInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ interface FormatterInterface
2727
* @return string
2828
*/
2929
public function format(LogEntryInterface $entry): string;
30-
}
30+
}

src/Handler/EchoHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ protected function write(LogEntryInterface $entry)
2727
{
2828
echo $this->getFormatter()->format($entry);
2929
}
30-
}
30+
}

src/Handler/HandlerAbstract.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ protected function isHandling(): bool
7676
* @param LogEntryInterface $entry
7777
*/
7878
abstract protected function write(LogEntryInterface $entry);
79-
}
79+
}

src/Handler/HandlerAwareInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ public function addHandler(
4646
* @return Traversable
4747
*/
4848
public function getHandlers(LogEntryInterface $entry): Traversable;
49-
}
49+
}

src/Handler/HandlerAwareTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ protected function matchLevel(string $entryLevel, string $handlerLevel): bool
8888
}
8989
return FALSE;
9090
}
91-
}
91+
}

src/Handler/HandlerInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ interface HandlerInterface
2727
* @return LogEntryInterface
2828
*/
2929
public function handle(LogEntryInterface $entry): LogEntryInterface;
30-
}
30+
}

src/Handler/LogfileHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ protected function rotateByDate(string $path, string $format = 'Ymd'): bool
107107
return FALSE;
108108
}
109109
}
110-
}
110+
}

src/Handler/StreamHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ protected function write(LogEntryInterface $entry)
7878
flock($this->stream, LOCK_UN);
7979
}
8080
}
81-
}
81+
}

src/Handler/SyslogHandler.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ class SyslogHandler extends HandlerAbstract
5454
* @access protected
5555
*/
5656
protected $priorities = [
57-
LogLevel::DEBUG => LOG_DEBUG,
58-
LogLevel::INFO => LOG_INFO,
59-
LogLevel::NOTICE => LOG_NOTICE,
60-
LogLevel::WARNING => LOG_WARNING,
61-
LogLevel::ERROR => LOG_ERR,
62-
LogLevel::CRITICAL => LOG_CRIT,
63-
LogLevel::ALERT => LOG_ALERT,
57+
LogLevel::DEBUG => LOG_DEBUG,
58+
LogLevel::INFO => LOG_INFO,
59+
LogLevel::NOTICE => LOG_NOTICE,
60+
LogLevel::WARNING => LOG_WARNING,
61+
LogLevel::ERROR => LOG_ERR,
62+
LogLevel::CRITICAL => LOG_CRIT,
63+
LogLevel::ALERT => LOG_ALERT,
6464
LogLevel::EMERGENCY => LOG_EMERG,
6565
];
6666

@@ -95,4 +95,4 @@ protected function write(LogEntryInterface $entry)
9595
);
9696
closelog();
9797
}
98-
}
98+
}

src/Handler/TerminalHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ protected function isHandling(): bool
4343
{
4444
return 'cli' === php_sapi_name();
4545
}
46-
}
46+
}

src/Logger.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function log($level, $message, array $context = array())
4949
{
5050
// init the log entry
5151
$entry = $this->initEntry($message, $level, $context);
52+
5253
/** @var HandlerInterface $handler */
5354
foreach ($this->getHandlers($entry) as $handler) {
5455
$entry = $handler->handle($entry);
@@ -69,6 +70,7 @@ protected function initEntry($message, string $level, array $context): LogEntryI
6970
$entry = new LogEntry($message);
7071
}
7172
$this->setChannel($context);
73+
7274
return $entry
7375
->setLevel($level)
7476
->setContext(array_merge($entry->getContext(), $context));
@@ -83,4 +85,4 @@ protected function setChannel(array &$context)
8385
$context['__channel'] = $this->channel;
8486
}
8587
}
86-
}
88+
}

src/Processor/MemoryProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ protected function updateContext(array $context): array
2727
$context['memory_peak'] = number_format(memory_get_peak_usage(TRUE) / 1048575, 2);
2828
return $context;
2929
}
30-
}
30+
}

0 commit comments

Comments
 (0)