KEYCLOAK-1280: i18n logging for org.keycloak.services.messages
This commit is contained in:
parent
779a5c2f3c
commit
857201ab55
2 changed files with 28 additions and 4 deletions
|
@ -287,4 +287,12 @@ public interface ServicesLogger extends BasicLogger {
|
|||
@LogMessage(level = ERROR)
|
||||
@Message(id=62, value="Error occurred during sync of changed users")
|
||||
void errorDuringChangedUserSync(@Cause Throwable t);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(id=63, value="Failed to format message due to: %s")
|
||||
void failedToFormatMessage(String cause);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(id=64, value="Failed to load messages")
|
||||
void failedToloadMessages(@Cause IOException ioe);
|
||||
}
|
||||
|
|
|
@ -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.messages;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -5,16 +21,16 @@ import java.net.URL;
|
|||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.messages.MessagesProvider;
|
||||
import org.keycloak.services.ServicesLogger;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:leonardo.zanivan@gmail.com">Leonardo Zanivan</a>
|
||||
*/
|
||||
public class AdminMessagesProvider implements MessagesProvider {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AdminMessagesProvider.class);
|
||||
private static final ServicesLogger logger = ServicesLogger.ROOT_LOGGER;
|
||||
|
||||
private KeycloakSession session;
|
||||
private Locale locale;
|
||||
|
@ -33,7 +49,7 @@ public class AdminMessagesProvider implements MessagesProvider {
|
|||
try {
|
||||
return new MessageFormat(message, locale).format(parameters);
|
||||
} catch (Exception e) {
|
||||
logger.warnf("Failed to format message due to: %s", e.getMessage());
|
||||
logger.failedToFormatMessage(e.getMessage());
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +71,7 @@ public class AdminMessagesProvider implements MessagesProvider {
|
|||
try {
|
||||
properties.load(url.openStream());
|
||||
} catch (IOException ex) {
|
||||
logger.warn("Failed to load messages", ex);
|
||||
logger.failedToloadMessages(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue