KEYCLOAK-1280: i18n logging for org.keycloak.services
This commit is contained in:
parent
1f04676f08
commit
27ad9dcdd1
4 changed files with 70 additions and 14 deletions
16
services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java
Executable file → Normal file
16
services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java
Executable file → Normal file
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors
|
||||||
|
* as indicated by the @author tags. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
package org.keycloak.services;
|
package org.keycloak.services;
|
||||||
|
|
||||||
import org.keycloak.models.*;
|
import org.keycloak.models.*;
|
||||||
|
|
32
services/src/main/java/org/keycloak/services/DefaultKeycloakSessionFactory.java
Executable file → Normal file
32
services/src/main/java/org/keycloak/services/DefaultKeycloakSessionFactory.java
Executable file → Normal file
|
@ -1,6 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors
|
||||||
|
* as indicated by the @author tags. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
package org.keycloak.services;
|
package org.keycloak.services;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
import org.keycloak.Config;
|
import org.keycloak.Config;
|
||||||
import org.keycloak.models.KeycloakSession;
|
import org.keycloak.models.KeycloakSession;
|
||||||
import org.keycloak.models.KeycloakSessionFactory;
|
import org.keycloak.models.KeycloakSessionFactory;
|
||||||
|
@ -10,6 +25,7 @@ import org.keycloak.provider.ProviderEventListener;
|
||||||
import org.keycloak.provider.ProviderFactory;
|
import org.keycloak.provider.ProviderFactory;
|
||||||
import org.keycloak.provider.ProviderManager;
|
import org.keycloak.provider.ProviderManager;
|
||||||
import org.keycloak.provider.Spi;
|
import org.keycloak.provider.Spi;
|
||||||
|
import org.keycloak.services.ServicesLogger;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -22,7 +38,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
public class DefaultKeycloakSessionFactory implements KeycloakSessionFactory {
|
public class DefaultKeycloakSessionFactory implements KeycloakSessionFactory {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(DefaultKeycloakSessionFactory.class);
|
private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER;
|
||||||
|
|
||||||
private Map<Class<? extends Provider>, String> provider = new HashMap<Class<? extends Provider>, String>();
|
private Map<Class<? extends Provider>, String> provider = new HashMap<Class<? extends Provider>, String>();
|
||||||
private Map<Class<? extends Provider>, Map<String, ProviderFactory>> factoriesMap = new HashMap<Class<? extends Provider>, Map<String, ProviderFactory>>();
|
private Map<Class<? extends Provider>, Map<String, ProviderFactory>> factoriesMap = new HashMap<Class<? extends Provider>, Map<String, ProviderFactory>>();
|
||||||
|
@ -70,12 +86,12 @@ public class DefaultKeycloakSessionFactory implements KeycloakSessionFactory {
|
||||||
factory.init(scope);
|
factory.init(scope);
|
||||||
|
|
||||||
if (spi.isInternal() && !isInternal(factory)) {
|
if (spi.isInternal() && !isInternal(factory)) {
|
||||||
log.warnv("{0} ({1}) is implementing the internal SPI {2}. This SPI is internal and may change without notice", factory.getId(), factory.getClass().getName(), spi.getName());
|
logger.spiMayChange(factory.getId(), factory.getClass().getName(), spi.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
factories.put(factory.getId(), factory);
|
factories.put(factory.getId(), factory);
|
||||||
|
|
||||||
log.debugv("Loaded SPI {0} (provider = {1})", spi.getName(), provider);
|
logger.debugv("Loaded SPI {0} (provider = {1})", spi.getName(), provider);
|
||||||
} else {
|
} else {
|
||||||
for (ProviderFactory factory : pm.load(spi)) {
|
for (ProviderFactory factory : pm.load(spi)) {
|
||||||
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
|
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
|
||||||
|
@ -83,12 +99,12 @@ public class DefaultKeycloakSessionFactory implements KeycloakSessionFactory {
|
||||||
factory.init(scope);
|
factory.init(scope);
|
||||||
|
|
||||||
if (spi.isInternal() && !isInternal(factory)) {
|
if (spi.isInternal() && !isInternal(factory)) {
|
||||||
log.warnv("{0} ({1}) is implementing the internal SPI {2}. This SPI is internal and may change without notice", factory.getId(), factory.getClass().getName(), spi.getName());
|
logger.spiMayChange(factory.getId(), factory.getClass().getName(), spi.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
factories.put(factory.getId(), factory);
|
factories.put(factory.getId(), factory);
|
||||||
} else {
|
} else {
|
||||||
log.debugv("SPI {0} provider {1} disabled", spi.getName(), factory.getId());
|
logger.debugv("SPI {0} provider {1} disabled", spi.getName(), factory.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,9 +112,9 @@ public class DefaultKeycloakSessionFactory implements KeycloakSessionFactory {
|
||||||
provider = factories.values().iterator().next().getId();
|
provider = factories.values().iterator().next().getId();
|
||||||
this.provider.put(spi.getProviderClass(), provider);
|
this.provider.put(spi.getProviderClass(), provider);
|
||||||
|
|
||||||
log.debugv("Loaded SPI {0} (provider = {1})", spi.getName(), provider);
|
logger.debugv("Loaded SPI {0} (provider = {1})", spi.getName(), provider);
|
||||||
} else {
|
} else {
|
||||||
log.debugv("Loaded SPI {0} (providers = {1})", spi.getName(), factories.keySet());
|
logger.debugv("Loaded SPI {0} (providers = {1})", spi.getName(), factories.keySet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2016 Red Hat Inc. and/or its affiliates and other contributors
|
||||||
|
* as indicated by the @author tags. All rights reserved.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations under
|
||||||
|
* the License.
|
||||||
|
*/
|
||||||
package org.keycloak.services;
|
package org.keycloak.services;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
import org.keycloak.models.KeycloakTransaction;
|
import org.keycloak.models.KeycloakTransaction;
|
||||||
import org.keycloak.models.KeycloakTransactionManager;
|
import org.keycloak.models.KeycloakTransactionManager;
|
||||||
|
import org.keycloak.services.ServicesLogger;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -12,7 +28,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class DefaultKeycloakTransactionManager implements KeycloakTransactionManager {
|
public class DefaultKeycloakTransactionManager implements KeycloakTransactionManager {
|
||||||
|
|
||||||
public static final Logger logger = Logger.getLogger(DefaultKeycloakTransactionManager.class);
|
public static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER;
|
||||||
|
|
||||||
private List<KeycloakTransaction> transactions = new LinkedList<KeycloakTransaction>();
|
private List<KeycloakTransaction> transactions = new LinkedList<KeycloakTransaction>();
|
||||||
private List<KeycloakTransaction> afterCompletion = new LinkedList<KeycloakTransaction>();
|
private List<KeycloakTransaction> afterCompletion = new LinkedList<KeycloakTransaction>();
|
||||||
|
@ -75,7 +91,7 @@ public class DefaultKeycloakTransactionManager implements KeycloakTransactionMan
|
||||||
try {
|
try {
|
||||||
tx.rollback();
|
tx.rollback();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
logger.error("Exception during rollback", e);
|
logger.exceptionDuringRollback(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,4 +221,12 @@ public interface ServicesLogger extends BasicLogger {
|
||||||
@LogMessage(level = WARN)
|
@LogMessage(level = WARN)
|
||||||
@Message(id=46, value="Multiple values found '%s' for protocol mapper '%s' but expected just single value")
|
@Message(id=46, value="Multiple values found '%s' for protocol mapper '%s' but expected just single value")
|
||||||
void multipleValuesForMapper(String attrValue, String mapper);
|
void multipleValuesForMapper(String attrValue, String mapper);
|
||||||
|
|
||||||
|
@LogMessage(level = WARN)
|
||||||
|
@Message(id=47, value="%s (%s) is implementing the internal SPI %s. This SPI is internal and may change without notice")
|
||||||
|
void spiMayChange(String factoryId, String factoryClass, String spiName);
|
||||||
|
|
||||||
|
@LogMessage(level = ERROR)
|
||||||
|
@Message(id=48, value="Exception during rollback")
|
||||||
|
void exceptionDuringRollback(@Cause RuntimeException e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue