/** * * @param \Sooh\Base\Log\Data $logData */ public function write($logData) { $resChg = $logData->resChanged; $arr = $logData->toArray(); unset($arr['resChanged']); unset($arr['logGuid']); \Sooh\DB\Cases\LogStorage::$__YMD = \Sooh\Base\Time::getInstance()->YmdFull; \Sooh\DB\Cases\LogStorage::$__id_in_dbByObj = 'dbgrpForLog'; \Sooh\DB\Cases\LogStorage::$__type = 'a'; \Sooh\DB\Cases\LogStorage::$__nSplitedBy = $this->tbSplit; //\Sooh\DB\Cases\LogStorage::$__fields=array(.....); $tmp = \Sooh\DB\Cases\LogStorage::getCopy($logData->logGuid); foreach ($arr as $k => $v) { $tmp->setField($k, $v); } $ret = $tmp->writeLog(); if ($ret) { $tbSub = str_replace('_a_', '_b_', $tmp->tbname()); foreach ($resChg as $r) { $r['logGuid'] = $logData->logGuid; try { \Sooh\DB\Broker::errorMarkSkip(\Sooh\DB\Error::tableNotExists); $tmp->db()->addRecord($tbSub, $r); } catch (\ErrorException $e) { if (\Sooh\DB\Broker::errorIs($e, \Sooh\DB\Error::tableNotExists)) { $tmp->db()->ensureObj($tbSub, array('logGuid' => 'bigint unsigned not null default 0', 'resName' => "varchar(36) not null default ''", 'resChg' => "int not null default 0", 'resNew' => "int not null default 0")); $tmp->db()->addRecord($tbSub, $r); } else { error_log("write log failed:" . $e->getMessage() . "\n" . \Sooh\DB\Broker::lastCmd()); } } } } }
/** * * @param \Sooh\Base\Log\Data $logData */ public function write($logData) { $arr = $logData->toArray(); $ret = array('ret' => $arr['ret']); unset($arr['ret']); $arr = array_merge($ret, $arr); $fullname = $this->path . '/' . $logData->ymd . '-' . $this->file; file_put_contents($fullname, json_encode($arr), FILE_APPEND); }
/** * * @param \Sooh\Base\Log\Data $logData */ public function write($logData) { $arr = $logData->toArray(); $ret = array('ret' => $arr['ret']); unset($arr['ret']); $arr = array_merge($ret, $arr); if ($this->fullname === '/') { error_log(json_encode($arr)); } else { file_put_contents($this->fullname, '[' . date('m-d H:i:s') . ']' . json_encode($arr), FILE_APPEND); } }