public static function init($conf) { if (!file_exists($conf->dir)) { if (!mkdir($conf->dir, 0777, true)) { echo "[fail to init log][can not mkdir][path: {$conf->dir}]<br>"; return false; } } $ret = ub_log_init($conf->dir, $conf->file, $conf->severity, $conf->format, $conf->flush); if (!$ret) { return $ret; } // self::$_logfile = fopen("$conf->dir/$conf->file", "a+"); // echo "[start log][write log to $conf->dir/$conf->file]<br>"; self::$_severity = $conf->severity; self::$_disable_ostream = $conf->disable_ostream; self::$_logconf = $conf; return true; }
function cy_init_log() { $c = $_ENV['config']['log']; if (PHP_SAPI === 'cli') { $name = basename($_SERVER['SCRIPT_NAME']); $dir = dirname($_SERVER['SCRIPT_NAME']); $base = basename($dir); if ($base === 'sbin') { $c['name'] = $name; } } ub_log_init($c['path'], $c['name'], $c['level'], [], $c['fflush']); }