Skip to content

Commit

Permalink
Release v4.0.0 - Support PHP >=8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hungnguyenhp committed Jul 14, 2022
1 parent 48bd4a2 commit d449dc6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
php-versions: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
php-versions: [ '8.1' ]
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

- [x] V1.x, V2.x support all PHP version `>=5.6`
- [x] V3.x support all PHP version `>=7.0`
- [x] V4.x support all PHP version `>=8.1`

## Dependents

Thư viện có sử dụng các gói sau đây

- [x] monolog/monolog `^2.3`
- [x] monolog/monolog `^3.0`
- [x] cocur/slugify `^4.0`
- [x] theseer/directoryscanner `^1.3`
- [x] symfony/filesystem `^5.3 || ^4.4`
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
}
],
"require": {
"php": "^7.0 || ^8.0",
"php": ">=8.1",
"ext-json": "*",
"ext-mbstring": "*",
"nguyenanhung/benchmark": "^2.0 || ^1.0",
"nguyenanhung/filesystem-helper": "^2.0 || ^1.0",
"nguyenanhung/slug-helper": "^2.0 || ^1.0",
"monolog/monolog": "^2.0 || ^1.26"
"monolog/monolog": "^3.1"
},
"require-dev": {
"kint-php/kint": ">=3.0"
Expand Down
63 changes: 27 additions & 36 deletions src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function setLoggerLineFormat(string $loggerLineFormat = null): Logger
*
* @example log('info', 'test', 'Log Test', [])
*/
public function log(string $level = '', string $name = 'log', string $msg = 'My Message', $context = array())
public function log(string $level = '', string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand Down Expand Up @@ -356,33 +356,24 @@ public function log(string $level = '', string $name = 'log', string $msg = 'My
// Default Level is INFO
$useLevel = in_array($level, $listLevel) ? trim($level) : trim('info');
}
switch ($useLevel) {
case 'debug':
$keyLevel = MonoLogger::DEBUG;
break;
case 'info':
$keyLevel = MonoLogger::INFO;
break;
case 'notice':
$keyLevel = MonoLogger::NOTICE;
break;
case 'warning':
$keyLevel = MonoLogger::WARNING;
break;
case 'error':
$keyLevel = MonoLogger::ERROR;
break;
case 'critical':
$keyLevel = MonoLogger::CRITICAL;
break;
case 'alert':
$keyLevel = MonoLogger::ALERT;
break;
case 'emergency':
$keyLevel = MonoLogger::EMERGENCY;
break;
default:
$keyLevel = MonoLogger::WARNING;
if ($useLevel == 'debug') {
$keyLevel = MonoLogger::DEBUG;
} elseif ($useLevel == 'info') {
$keyLevel = MonoLogger::INFO;
} elseif ($useLevel == 'notice') {
$keyLevel = MonoLogger::NOTICE;
} elseif ($useLevel == 'warning') {
$keyLevel = MonoLogger::WARNING;
} elseif ($useLevel == 'error') {
$keyLevel = MonoLogger::ERROR;
} elseif ($useLevel == 'critical') {
$keyLevel = MonoLogger::CRITICAL;
} elseif ($useLevel == 'alert') {
$keyLevel = MonoLogger::ALERT;
} elseif ($useLevel == 'emergency') {
$keyLevel = MonoLogger::EMERGENCY;
} else {
$keyLevel = MonoLogger::WARNING;
}
$loggerFilename = $this->loggerPath . DIRECTORY_SEPARATOR . $loggerSubPath . DIRECTORY_SEPARATOR . $this->loggerFilename;
$dateFormat = !empty($this->loggerDateFormat) ? $this->loggerDateFormat : "Y-m-d H:i:s u";
Expand Down Expand Up @@ -427,7 +418,7 @@ public function log(string $level = '', string $name = 'log', string $msg = 'My
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function debug(string $name = 'log', string $msg = 'My Message', $context = array())
public function debug(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand All @@ -449,7 +440,7 @@ public function debug(string $name = 'log', string $msg = 'My Message', $context
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function info(string $name = 'log', string $msg = 'My Message', $context = array())
public function info(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand All @@ -471,7 +462,7 @@ public function info(string $name = 'log', string $msg = 'My Message', $context
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function notice(string $name = 'log', string $msg = 'My Message', $context = array())
public function notice(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand All @@ -493,7 +484,7 @@ public function notice(string $name = 'log', string $msg = 'My Message', $contex
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function warning(string $name = 'log', string $msg = 'My Message', $context = array())
public function warning(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand All @@ -515,7 +506,7 @@ public function warning(string $name = 'log', string $msg = 'My Message', $conte
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function error(string $name = 'log', string $msg = 'My Message', $context = array())
public function error(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand All @@ -537,7 +528,7 @@ public function error(string $name = 'log', string $msg = 'My Message', $context
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function critical(string $name = 'log', string $msg = 'My Message', $context = array())
public function critical(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand All @@ -559,7 +550,7 @@ public function critical(string $name = 'log', string $msg = 'My Message', $cont
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function alert(string $name = 'log', string $msg = 'My Message', $context = array())
public function alert(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand All @@ -581,7 +572,7 @@ public function alert(string $name = 'log', string $msg = 'My Message', $context
* @copyright: 713uk13m <[email protected]>
* @time : 08/17/2021 07:35
*/
public function emergency(string $name = 'log', string $msg = 'My Message', $context = array())
public function emergency(string $name = 'log', string $msg = 'My Message', array|string $context = array())
{
if (!is_array($context)) {
$context = array($context);
Expand Down
2 changes: 1 addition & 1 deletion src/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
interface Project
{
const VERSION = '3.0.7';
const VERSION = '4.0.0';

/**
* Hàm lấy thông tin phiên bản Packages
Expand Down

0 comments on commit d449dc6

Please sign in to comment.