-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from cesargb/prev2
v2 api
- Loading branch information
Showing
14 changed files
with
405 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Listen for XDebug", | ||
"type": "php", | ||
"request": "launch", | ||
"port": 9000 | ||
}, | ||
{ | ||
"name": "Launch currently open script", | ||
"type": "php", | ||
"request": "launch", | ||
"program": "${file}", | ||
"cwd": "${fileDirname}", | ||
"port": 9000 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Cesargb\Log\Compress; | ||
|
||
use Exception; | ||
|
||
class Gz | ||
{ | ||
const EXTENSION_COMPRESS = 'gz'; | ||
|
||
public function handler($file): string | ||
{ | ||
$fileCompress = $file.'.'.self::EXTENSION_COMPRESS; | ||
|
||
$fd = fopen($file, 'r'); | ||
|
||
if (!$fd) { | ||
throw new Exception("file {$file} not can read.", 100); | ||
} | ||
|
||
$gz = gzopen($fileCompress, 'wb'); | ||
|
||
if (! $gz) { | ||
fclose($fd); | ||
|
||
throw new Exception("file {$fileCompress} not can open.", 101); | ||
} | ||
|
||
while (! feof($fd)) { | ||
gzwrite($gz, fread($fd, 1024 * 512)); | ||
} | ||
|
||
gzclose($gz); | ||
fclose($fd); | ||
unlink($file); | ||
|
||
return $fileCompress; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Cesargb\Log; | ||
|
||
use Throwable; | ||
|
||
class ErrorHandler | ||
{ | ||
private $catchCallable = null; | ||
|
||
public function catch(callable $callable): self | ||
{ | ||
$this->catchCallable = $callable; | ||
|
||
return $this; | ||
} | ||
|
||
public function exception(Throwable $exception): self | ||
{ | ||
if ($this->catchCallable) { | ||
call_user_func($this->catchCallable, $exception); | ||
} else { | ||
throw $exception; | ||
} | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.