-
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.
- Loading branch information
1 parent
2b1a31c
commit 5f6f438
Showing
23 changed files
with
306 additions
and
99 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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pattern: '<%{POSINT:pri}>%{POSINT:version} %{TIMESTAMP_ISO8601:timestamp} %{HOSTNAME:hostname} %{USERNAME:table_name} %{USERNAME:proc_id} %{USERNAME:app_name} \- %{GREEDYDATA:message}' | ||
pattern: '<%{POSINT:pri}>%{POSINT:version} %{TIMESTAMP_ISO8601:timestamp} %{HOSTNAME:hostname} %{USERNAME:table_name} %{USERNAME:proc_id} %{USERNAME:app_name} (\[%{DATA:structured_data}\]|\-) %{GREEDYDATA:message}' |
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
File renamed without changes.
File renamed without changes.
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,36 @@ | ||
<?php | ||
|
||
namespace App\Config; | ||
|
||
use App\Exceptions\ConfigFileInvalid; | ||
use App\Exceptions\ConfigFileNotFound; | ||
use App\Logger\Logger; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
class Config | ||
{ | ||
public static function read($filename, $key, $default = '') | ||
{ | ||
$path = $_ENV['ROOT_DIR'] . "/config/{$filename}.y{ml,aml}"; | ||
$files = glob($path, GLOB_BRACE); | ||
|
||
if (empty($files)) { | ||
throw new ConfigFileNotFound("Config file not found. Please create a config file \"{$filename}.yaml\" in \/config directory"); | ||
} | ||
|
||
$configFile = array_shift($files); | ||
$config = Yaml::parseFile($configFile); | ||
|
||
if (empty($config)) { | ||
throw new ConfigFileInvalid("The file {$configFile} could not be read or the YAML is not valid"); | ||
} | ||
|
||
if (!array_key_exists($key, $config)) { | ||
Logger::debug("Key \"{$key}\" does not exist in config file, return default value \"{$default}\""); | ||
|
||
return $default; | ||
} | ||
|
||
return $config[$key]; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Enum; | ||
|
||
enum LogLevel: string | ||
{ | ||
case DEBUG = 'debug'; | ||
case ERROR = 'error'; | ||
|
||
public function value(): int | ||
{ | ||
return match ($this) { | ||
LogLevel::DEBUG => SWOOLE_LOG_DEBUG, | ||
LogLevel::ERROR => SWOOLE_LOG_ERROR, | ||
}; | ||
} | ||
} |
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,8 @@ | ||
<?php | ||
|
||
namespace App\Exceptions; | ||
|
||
class ConfigFileInvalid extends \Exception | ||
{ | ||
protected $message = 'The file could not be read or the YAML is not valid'; | ||
} |
Oops, something went wrong.