diff --git a/CHANGELOG.md b/CHANGELOG.md index db1f3af3f..81141a788 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Fixed - otpPolicyAlgorithm ignored during import [#847](https://github.com/adorsys/keycloak-config-cli/issues/847) +## Added +- Enhance Standard output logging [#1215](https://github.com/adorsys/keycloak-config-cli/issues/1215) + ### Added - Added Navigation in the readme [#1099](https://github.com/adorsys/keycloak-config-cli/issues/1099) ### Added diff --git a/src/main/java/de/adorsys/keycloak/config/service/RealmImportService.java b/src/main/java/de/adorsys/keycloak/config/service/RealmImportService.java index c1af0878e..fad4eed42 100644 --- a/src/main/java/de/adorsys/keycloak/config/service/RealmImportService.java +++ b/src/main/java/de/adorsys/keycloak/config/service/RealmImportService.java @@ -173,37 +173,61 @@ private void setEventsEnabledWorkaround(RealmImport realmImport) { } private void createRealm(RealmImport realmImport) { - logger.debug("Creating realm '{}' ...", realmImport.getRealm()); + logger.info("Starting creation of realm '{}'", realmImport.getRealm()); RealmRepresentation realm = CloneUtil.deepClone(realmImport, RealmRepresentation.class, ignoredPropertiesForRealmImport); + logger.debug("RealmRepresentation created: {}", realm); + logger.info("Creating realm in repository"); realmRepository.create(realm); + logger.info("Realm '{}' created successfully", realm.getRealm()); - // refresh the access token to update the scopes. See: https://github.com/adorsys/keycloak-config-cli/issues/339 + logger.debug("Refreshing access token to update scopes"); keycloakProvider.refreshToken(); + logger.debug("Access token refreshed"); + logger.debug("Loading state for realm '{}'", realmImport.getRealm()); stateService.loadState(realmImport); + logger.debug("State loaded for realm '{}'", realmImport.getRealm()); + logger.info("Configuring realm '{}'", realmImport.getRealm()); configureRealm(realmImport, realm); + logger.info("Configuration completed for realm '{}'", realmImport.getRealm()); + logger.info("Creation of realm '{}' completed", realmImport.getRealm()); } private void updateRealm(RealmImport realmImport) { - logger.debug("Updating realm '{}'...", realmImport.getRealm()); + logger.info("Starting update of realm '{}'", realmImport.getRealm()); + logger.debug("Cloning realm import to RealmRepresentation"); RealmRepresentation realm = CloneUtil.deepClone(realmImport, RealmRepresentation.class, ignoredPropertiesForRealmImport); + logger.debug("RealmRepresentation created for update: {}", realm); + logger.info("Fetching existing realm '{}'", realmImport.getRealm()); RealmRepresentation existingRealm = realmRepository.get(realmImport.getRealm()); + logger.debug("Existing realm retrieved: {}", existingRealm); if (existingRealm.getEventsExpiration() != null) { + logger.debug("Preserving events expiration: {}", existingRealm.getEventsExpiration()); realm.setEventsExpiration(existingRealm.getEventsExpiration()); } + logger.info("Updating OTP policy for realm '{}'", realmImport.getRealm()); otpPolicyImportService.updateOtpPolicy(realmImport.getRealm(), realm); + logger.debug("OTP policy updated for realm '{}'", realmImport.getRealm()); + logger.debug("Loading state for updated realm '{}'", realmImport.getRealm()); stateService.loadState(realm); + logger.debug("State loaded for updated realm '{}'", realmImport.getRealm()); + logger.info("Updating realm in repository"); realmRepository.update(realm); + logger.info("Realm '{}' updated successfully", realm.getRealm()); + logger.info("Configuring updated realm '{}'", realmImport.getRealm()); configureRealm(realmImport, realm); + logger.info("Configuration completed for updated realm '{}'", realmImport.getRealm()); + logger.info("Update of realm '{}' completed", realmImport.getRealm()); } + private void importOtpPolicy(RealmImport realmImport) { RealmRepresentation realmConfig = realmRepository.get(realmImport.getRealm()); if (realmConfig.getOtpPolicyAlgorithm() != null) {