function logMsg($level, $msg) { global $logLevel; if ($level <= $logLevel) { error_log($msg . "\r\n", 3, getLogFilePath()); } }
//mysql $di->set("db", function () use($mysql_config) { $connection = new PdoMysql(array("host" => $mysql_config['host'], "username" => $mysql_config['username'], "password" => $mysql_config['password'], "dbname" => $mysql_config['dbname'], "options" => array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'", PDO::ATTR_CASE => PDO::CASE_LOWER))); $eventsManager = new EventsManager(); $logger = new LoggerFile(getLogFilePath(DB_LOOGER_DIR, DB_LOG_SIZE, 'db_logs_')); $eventsManager->attach('db', function ($event, $connection) use($logger) { if ($event->getType() == 'beforeQuery') { $logger->log($connection->getSQLStatement(), Logger::INFO); } }); $connection->setEventsManager($eventsManager); return $connection; }); // Logger $di->set('logger', function () { return new LoggerFile(getLogFilePath(LOOGER_DIR, LOG_SIZE, 'logs_')); }); //Router $di->set('router', function () { $router = (require __DIR__ . '/Route.php'); return $router; }); //view $di->set('voltService', function ($view, $di) { $volt = new Volt($view, $di); $volt->setOptions(array("compiledPath" => ROOT_DIR . "/Caches/ViewsCache/", "compiledExtension" => ".view_cache")); return $volt; }); $di->set('view', function () { $view = new View(); $view->setViewsDir(ROOT_DIR . '/Views/');