'File', 'path' => LOGS, 'levels' => [], 'scopes' => ['custom'], 'file' => $filename, ]); static::$_debugConfig = CoreLog::getConfig('debug'); CoreLog::drop('debug'); } /** * Log data into custom file * * @param \ArrayObject|array|string $data Data to store * @param string|null $filename Filename of log file * @param bool $traceKey Add trace string key into log data * @return bool Success */ public static function write($data, $filename = null, $traceKey = false): bool { static::_init($filename); // Pretty print array or object if (is_array($data) || is_object($data)) { if ($traceKey) { try { throw new Exception('Trace string', 1); } catch (Throwable $t) { $data['trace_string'] = $t->getTraceAsString(); } } $data = print_r($data, true); } $logged = CoreLog::write('debug', $data, ['scope' => 'custom']); static::_cleanUp(); return $logged; } /** * Drop custom log config, set default `debug` config in log registry. * * @return void */ protected static function _cleanUp(): void { CoreLog::drop('custom'); CoreLog::setConfig('debug', static::$_debugConfig); } }