diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 9f7aa0ed..293c727d 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -38,7 +38,7 @@ class SetupController extends Controller // Not installed completely if (count($existingTables) > 0) { - Log::info('Remaining tables detected, exit setup wizard now', [$existingTables]); + Log::info('[SetupWizard] Remaining tables detected, exit now', [$existingTables]); $existingTables = array_map(function ($item) { return get_db_config()['prefix'].$item; @@ -70,22 +70,19 @@ class SetupController extends Controller Artisan::call('key:random'); Artisan::call('salt:random'); - Log::info("[SetupWizard] Random application key & salt set successfully.", [ - 'key' => config('app.key'), - 'salt' => config('secure.salt') - ]); + Log::info('[SetupWizard] Random application key & salt set successfully'); } else { // @codeCoverageIgnoreStart - Log::warning("[SetupWizard] Failed to set application key. No write permission."); + Log::warning('[SetupWizard] Failed to set application key since .env is not writable'); // @codeCoverageIgnoreEnd } } // Create tables Artisan::call('migrate', ['--force' => true]); - Log::info("[SetupWizard] Tables migrated."); + Log::info('[SetupWizard] Database migrated'); - Option::set('site_name', $request->input('site_name')); + Option::set('site_name', $request->get('site_name')); $siteUrl = url('/'); @@ -97,8 +94,8 @@ class SetupController extends Controller // Register super admin $user = User::register( - $request->input('email'), - $request->input('password'), function ($user) + $request->get('email'), + $request->get('password'), function ($user) { $user->ip = get_client_ip(); $user->score = option('user_initial_score'); @@ -106,14 +103,14 @@ class SetupController extends Controller $user->last_sign_at = get_datetime_string(time() - 86400); $user->permission = User::SUPER_ADMIN; }); - Log::info("[SetupWizard] Super Admin registered.", ['user' => $user]); + Log::info('[SetupWizard] Super administrator registered'); $this->createDirectories(); - Log::info("[SetupWizard] Installation completed."); + Log::info('[SetupWizard] Installation completed'); return view('setup.wizard.finish')->with([ - 'email' => $request->input('email'), - 'password' => $request->input('password') + 'email' => $request->get('email'), + 'password' => $request->get('password') ]); } @@ -173,7 +170,7 @@ class SetupController extends Controller try { Artisan::call('view:clear'); } catch (\Exception $e) { - Log::error('Error occured when processing view:clear', [$e]); + Log::error('[UpdateWizard] Error occured when processing view:clear', [$e]); $files = collect(File::files(storage_path('framework/views'))); $files->reject(function ($path) { diff --git a/app/Http/Controllers/UpdateController.php b/app/Http/Controllers/UpdateController.php index e9add8fe..9aa2fd92 100644 --- a/app/Http/Controllers/UpdateController.php +++ b/app/Http/Controllers/UpdateController.php @@ -132,7 +132,7 @@ class UpdateController extends Controller // Set temporary path for the update package $tmp_path = $update_cache.'/update_'.time().'.zip'; Cache::put('tmp_path', $tmp_path, 60); - Log::info('[Update Wizard] Prepare to download update package', compact('release_url', 'tmp_path')); + Log::info('[UpdateWizard] Prepare to download update package', compact('release_url', 'tmp_path')); // We won't get remote file size here since HTTP HEAD method is not always reliable return json(compact('release_url', 'tmp_path')); @@ -146,7 +146,7 @@ class UpdateController extends Controller @set_time_limit(0); $GLOBALS['last_downloaded'] = 0; - Log::info('[Update Wizard] Start downloading update package'); + Log::info('[UpdateWizard] Start downloading update package'); try { $client->request('GET', $release_url, array_merge($guzzle_config, [ @@ -156,7 +156,7 @@ class UpdateController extends Controller // Log current progress per 100 KiB if ($total == $downloaded || floor($downloaded / 102400) > floor($GLOBALS['last_downloaded'] / 102400)) { $GLOBALS['last_downloaded'] = $downloaded; - Log::info('[Update Wizard] Download progress (in bytes):', [$total, $downloaded]); + Log::info('[UpdateWizard] Download progress (in bytes):', [$total, $downloaded]); Cache::put('download-progress', compact('total', 'downloaded'), 60); } } @@ -166,7 +166,7 @@ class UpdateController extends Controller return response(trans('admin.update.errors.prefix').$e->getMessage()); } - Log::info('[Update Wizard] Finished downloading update package'); + Log::info('[UpdateWizard] Finished downloading update package'); return json(compact('tmp_path')); @@ -186,7 +186,7 @@ class UpdateController extends Controller $res = $zip->open($tmp_path); if ($res === true) { - Log::info("[Update Wizard] Extracting file $tmp_path"); + Log::info("[UpdateWizard] Extracting file $tmp_path"); if ($zip->extractTo($extract_dir) === false) { return response(trans('admin.update.errors.prefix').'Cannot unzip file.'); @@ -201,7 +201,7 @@ class UpdateController extends Controller File::copyDirectory("$extract_dir/vendor", base_path('vendor')); } catch (Exception $e) { report($e); - Log::error('[Update Wizard] Unable to extract vendors'); + Log::error('[UpdateWizard] Unable to extract vendors'); // Skip copying vendor File::deleteDirectory("$extract_dir/vendor"); } @@ -209,21 +209,21 @@ class UpdateController extends Controller try { File::copyDirectory($extract_dir, base_path()); - Log::info('[Update Wizard] Overwrite with extracted files'); + Log::info('[UpdateWizard] Overwrite with extracted files'); } catch (Exception $e) { report($e); - Log::error('[Update Wizard] Error occured when overwriting files'); + Log::error('[UpdateWizard] Error occured when overwriting files'); // Response can be returned, while cache will be cleared // @see https://gist.github.com/g-plane/2f88ad582826a78e0a26c33f4319c1e0 return response(trans('admin.update.errors.overwrite').$e->getMessage()); } finally { File::deleteDirectory(storage_path('update_cache')); - Log::info('[Update Wizard] Cleaning cache'); + Log::info('[UpdateWizard] Cleaning cache'); } - Log::info('[Update Wizard] Done'); + Log::info('[UpdateWizard] Done'); return json(trans('admin.update.complete'), 0); default: