Server IP : 185.86.78.101 / Your IP : 216.73.216.124 Web Server : Apache System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /www/wwwroot/mifepriston.org/vendor/yiisoft/yii2/log/ |
Upload File : |
<?php /** * @link https://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license https://www.yiiframework.com/license/ */ namespace yii\log; use Yii; use yii\base\InvalidConfigException; use yii\db\Connection; use yii\db\Exception; use yii\di\Instance; use yii\helpers\VarDumper; /** * DbTarget stores log messages in a database table. * * The database connection is specified by [[db]]. Database schema could be initialized by applying migration: * * ``` * yii migrate --migrationPath=@yii/log/migrations/ * ``` * * If you don't want to use migration and need SQL instead, files for all databases are in migrations directory. * * You may change the name of the table used to store the data by setting [[logTable]]. * * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ class DbTarget extends Target { /** * @var Connection|array|string the DB connection object or the application component ID of the DB connection. * After the DbTarget object is created, if you want to change this property, you should only assign it * with a DB connection object. * Starting from version 2.0.2, this can also be a configuration array for creating the object. */ public $db = 'db'; /** * @var string name of the DB table to store cache content. Defaults to "log". */ public $logTable = '{{%log}}'; /** * Initializes the DbTarget component. * This method will initialize the [[db]] property to make sure it refers to a valid DB connection. * @throws InvalidConfigException if [[db]] is invalid. */ public function init() { parent::init(); $this->db = Instance::ensure($this->db, Connection::className()); } /** * Stores log messages to DB. * Starting from version 2.0.14, this method throws LogRuntimeException in case the log can not be exported. * @throws Exception * @throws LogRuntimeException */ public function export() { if ($this->db->getTransaction()) { // create new database connection, if there is an open transaction // to ensure insert statement is not affected by a rollback $this->db = clone $this->db; } $tableName = $this->db->quoteTableName($this->logTable); $sql = "INSERT INTO $tableName ([[level]], [[category]], [[log_time]], [[prefix]], [[message]]) VALUES (:level, :category, :log_time, :prefix, :message)"; $command = $this->db->createCommand($sql); foreach ($this->messages as $message) { list($text, $level, $category, $timestamp) = $message; if (!is_string($text)) { // exceptions may not be serializable if in the call stack somewhere is a Closure if ($text instanceof \Exception || $text instanceof \Throwable) { $text = (string) $text; } else { $text = VarDumper::export($text); } } if ($command->bindValues([ ':level' => $level, ':category' => $category, ':log_time' => $timestamp, ':prefix' => $this->getMessagePrefix($message), ':message' => $text, ])->execute() > 0) { continue; } throw new LogRuntimeException('Unable to export log through database!'); } } }