Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Interfaces/LoggerAwareInterface.php

This file was deleted.

125 changes: 0 additions & 125 deletions Interfaces/LoggerInterface.php

This file was deleted.

58 changes: 32 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
{
"name": "maplephp/log",
"version": "v1.0.2",
"type": "library",
"description": "PHP PSR-3 Logger library, standardized approach to logging messages.",
"keywords": ["psr3", "log", "logger", "filesystem", "database", "error log"],
"homepage": "https://wazabii.se",
"license": "Apache-2.0",
"authors": [
{
"name": "Daniel Ronkainen",
"email": "[email protected]"
},
{
"name": "MaplePHP",
"homepage": "https://wazabii.se"
}
],
"require": {
"php": ">=8.0",
"maplephp/http": "^1.0"
"name": "maplephp/log",
"type": "library",
"description": "PHP PSR-3 Logger library, standardized approach to logging messages.",
"keywords": [
"PSR-3",
"log",
"logger",
"filesystem",
"error log"
],
"homepage": "https://wazabii.se",
"license": "Apache-2.0",
"authors": [
{
"name": "Daniel Ronkainen",
"email": "[email protected]"
},
"autoload": {
"psr-4": {
"MaplePHP\\Log\\": ""
}
},
"minimum-stability": "dev"
{
"name": "MaplePHP",
"homepage": "https://wazabii.se"
}
],
"require": {
"php": ">=8.2",
"psr/log": "^3.0",
"maplephp/http": "^2.0"
},
"autoload": {
"psr-4": {
"MaplePHP\\Log\\": "src"
}
},
"minimum-stability": "dev"
}
2 changes: 1 addition & 1 deletion AbstractLogger.php → src/AbstractLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MaplePHP\Log;

use MaplePHP\Log\Interfaces\LoggerInterface;
use Psr\Log\LoggerInterface;

/**
* This is a simple Logger implementation that other Loggers can inherit from.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ErrorLogHandler extends AbstractHandler
public function __construct(?string $file = null)
{
ini_set("log_errors", "1");
if (!is_null($file)) {
if ($file !== null) {
ini_set("error_log", $file);
}
}
Expand Down
12 changes: 6 additions & 6 deletions Handlers/StreamHandler.php → src/Handlers/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace MaplePHP\Log\Handlers;

use MaplePHP\Http\Interfaces\StreamInterface;
use MaplePHP\Http\Stream;
use Psr\Http\Message\StreamInterface;

class StreamHandler extends AbstractHandler
{
Expand All @@ -21,7 +21,7 @@ public function __construct(string $file, ?int $size = null, ?int $count = null)
{
$this->file = basename($file);
$this->dir = dirname($file) . "/";
$this->size = !is_null($size) ? ($size * 1024) : $size;
$this->size = $size !== null ? ($size * 1024) : $size;
$this->count = $count;
}

Expand Down Expand Up @@ -49,7 +49,7 @@ public function handler(string $level, string $message, array $context, string $
*/
protected function stream(): StreamInterface
{
if (is_null($this->stream)) {
if ($this->stream === null) {
if (!is_writable($this->dir)) {
throw new \Exception("The directory \"{$this->dir}\" is not writable!", 1);
}
Expand All @@ -64,7 +64,7 @@ protected function stream(): StreamInterface
*/
protected function rotate(): void
{
if (!is_null($this->size)) {
if ($this->size !== null) {
$file = $this->dir . $this->file;
$filename = $this->fileInfo("filename");
$extension = $this->fileInfo("extension");
Expand All @@ -74,7 +74,7 @@ protected function rotate(): void
$count = count($files);
sort($files);

if (!is_null($this->count) && ($count >= $this->count)) {
if ($this->count !== null && ($count >= $this->count)) {
for ($i = 0; $i < (($count - $this->count) + 1); $i++) {
unlink($files[$i]);
}
Expand All @@ -92,7 +92,7 @@ protected function rotate(): void
*/
private function fileInfo(string $key): ?string
{
if (is_null($this->info)) {
if ($this->info === null) {
$this->info = pathinfo($this->file);
}
return ($this->info[$key] ?? null);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Logger.php → src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getContext(): array
*/
protected function getDate(): string
{
if (is_null($this->dateTime)) {
if ($this->dateTime === null) {
$this->dateTime = new \DateTime("now");
}
return $this->dateTime->format(static::DATETIME_FORMAT);
Expand Down
2 changes: 1 addition & 1 deletion LoggerAwareTrait.php → src/LoggerAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MaplePHP\Log;

use MaplePHP\Log\Interfaces\LoggerInterface;
use Psr\Log\LoggerInterface;

/**
* Basic Implementation of LoggerAwareInterface.
Expand Down
File renamed without changes.
File renamed without changes.