From 273c662b291cfc5c15c49092b42be3704fa79b7f Mon Sep 17 00:00:00 2001 From: Stan Silvert Date: Mon, 18 Jan 2016 16:07:11 -0500 Subject: [PATCH] KEYCLOAK-1280: i18n logging for org.keycloak.exportimport --- .../exportimport/ExportImportManager.java | 16 +++++------ .../org/keycloak/services/ServicesLogger.java | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java b/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java index a373de40ff..389a973345 100644 --- a/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java +++ b/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java @@ -1,7 +1,7 @@ package org.keycloak.exportimport; -import org.jboss.logging.Logger; +import org.keycloak.services.ServicesLogger; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; @@ -12,7 +12,7 @@ import java.io.IOException; */ public class ExportImportManager { - private static final Logger logger = Logger.getLogger(ExportImportManager.class); + private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER; private KeycloakSessionFactory sessionFactory; @@ -65,13 +65,13 @@ public class ExportImportManager { try { Strategy strategy = ExportImportConfig.getStrategy(); if (realmName == null) { - logger.infof("Full model import requested. Strategy: %s", strategy.toString()); + logger.fullModelImport(strategy.toString()); importProvider.importModel(sessionFactory, strategy); } else { - logger.infof("Import of realm '%s' requested. Strategy: %s", realmName, strategy.toString()); + logger.realmImportRequested(realmName, strategy.toString()); importProvider.importRealm(sessionFactory, realmName, strategy); } - logger.info("Import finished successfully"); + logger.importSuccess(); } catch (IOException e) { throw new RuntimeException("Failed to run import", e); } @@ -80,13 +80,13 @@ public class ExportImportManager { public void runExport() { try { if (realmName == null) { - logger.info("Full model export requested"); + logger.fullModelExportRequested(); exportProvider.exportModel(sessionFactory); } else { - logger.infof("Export of realm '%s' requested", realmName); + logger.realmExportRequested(realmName); exportProvider.exportRealm(sessionFactory, realmName); } - logger.info("Export finished successfully"); + logger.exportSuccess(); } catch (IOException e) { throw new RuntimeException("Failed to run export"); } diff --git a/services/src/main/java/org/keycloak/services/ServicesLogger.java b/services/src/main/java/org/keycloak/services/ServicesLogger.java index b7e7f8681f..5b61cedfb3 100644 --- a/services/src/main/java/org/keycloak/services/ServicesLogger.java +++ b/services/src/main/java/org/keycloak/services/ServicesLogger.java @@ -152,4 +152,32 @@ public interface ServicesLogger extends BasicLogger { @LogMessage(level = ERROR) @Message(id=29, value="Failed to send email") void failedToSendEmail(@Cause Exception e); + + @LogMessage(level = INFO) + @Message(id=30, value="Full model import requested. Strategy: %s") + void fullModelImport(String strategy); + + @LogMessage(level = INFO) + @Message(id=31, value="Import of realm '%s' requested. Strategy: %s") + void realmImportRequested(String realmName, String strategy); + + @LogMessage(level = INFO) + @Message(id=32, value="Import finished successfully") + void importSuccess(); + + @LogMessage(level = INFO) + @Message(id=33, value="Full model export requested") + void fullModelExportRequested(); + + @LogMessage(level = INFO) + @Message(id=34, value="Export of realm '%s' requested.") + void realmExportRequested(String realmName); + + @LogMessage(level = INFO) + @Message(id=35, value="Export finished successfully") + void exportSuccess(); + + + + }