diff --git a/.gitignore b/.gitignore index bc429f0..39524dd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /config/config.cfg /config/config.ini /vendor +/hanyuu.cfg diff --git a/config/config.example.cfg b/config/config.example.cfg deleted file mode 100644 index 58164db..0000000 --- a/config/config.example.cfg +++ /dev/null @@ -1,3 +0,0 @@ -database:dsn mariadb://username:password@:unix:/database?socket=/var/run/mysqld/mysqld.sock&charset=utf8mb4 - -site:name Hanyuu diff --git a/hanyuu.php b/hanyuu.php index 9ce27b6..04348da 100644 --- a/hanyuu.php +++ b/hanyuu.php @@ -12,7 +12,6 @@ define('HAU_CLI', PHP_SAPI === 'cli'); define('HAU_DEBUG', is_file(HAU_ROOT . '/.debug')); define('HAU_DIR_PUBLIC', HAU_ROOT . '/public'); define('HAU_DIR_SOURCE', HAU_ROOT . '/src'); -define('HAU_DIR_CONFIG', HAU_ROOT . '/config'); define('HAU_DIR_MIGRATIONS', HAU_ROOT . '/database'); define('HAU_DIR_TEMPLATES', HAU_ROOT . '/templates'); @@ -24,7 +23,20 @@ mb_internal_encoding('utf-8'); date_default_timezone_set('utc'); set_include_path(get_include_path() . PATH_SEPARATOR . HAU_ROOT); +$cfg = SharpConfig::fromFile(HAU_ROOT . '/hanyuu.cfg'); + +if($cfg->hasValues('sentry:dsn')) + (function($cfg) { + \Sentry\init([ + 'dsn' => $cfg->getString('dsn'), + 'traces_sample_rate' => $cfg->getFloat('tracesRate', 0.2), + 'profiles_sample_rate' => $cfg->getFloat('profilesRate', 0.2), + ]); + })($cfg->scopeTo('sentry')); + set_exception_handler(function(\Throwable $ex) { + \Sentry\captureException($ex); + if(HAU_CLI) die((string)$ex); @@ -40,8 +52,6 @@ set_exception_handler(function(\Throwable $ex) { die('