You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@shindig.apache.org by "Han Nguyen (JIRA)" <ji...@apache.org> on 2010/12/08 21:55:01 UTC

[jira] Commented: (SHINDIG-1477) Externalize logging messages to resource bundle for i18n.

    [ https://issues.apache.org/jira/browse/SHINDIG-1477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12969484#action_12969484 ] 

Han Nguyen commented on SHINDIG-1477:
-------------------------------------

Committed, code is in trunk.

> Externalize logging messages to resource bundle for i18n.
> ---------------------------------------------------------
>
>                 Key: SHINDIG-1477
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-1477
>             Project: Shindig
>          Issue Type: Improvement
>    Affects Versions: 3.0.0
>            Reporter: Han Nguyen
>            Assignee: Han Nguyen
>            Priority: Trivial
>             Fix For: 3.0.0
>
>
> Patch loaded on code review here: http://codereview.appspot.com/3318041/
> Externalize all logging messages level INFO, WARN, SEVERE. These messages are not intented for end user outward facing but rather for supporting/debugging the framework.
> 1. org.apache.shindig.common.logging.i18n.MessageKeys: Unique [key, value] pairs for i18n logging messages. The key is used as message key input in the log method and its value matched the key specified in the localized resource.properties file
> 2. shindig-common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties: is used for localization of messages. We'll keep the logging messages in this file, and we'll use the keys declared in the MessageKeys to access them.
> 3. Examples:
>     * Create a logger with the MessageKey attached:
> //class name for logging purpose
> private static final String classname = "org.apache.shindig.auth.AuthenticationServletFilter";
> private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
>     * Using Java logp and message key for logging message with i18n support. Make sure to add the keys in MessageKeys, and the localized logging text in the resource.properties file.
> if (LOG.isLoggable(Level.INFO)) {
> LOG.logp(Level.INFO, classname, "doFilter", MessageKeys.ERROR_PARSING_SECURE_TOKEN, cause);
> }
>     * Here's a simple example for compound message using template:
> if (LOG.isLoggable(Level.INFO)) {
> LOG.logp(Level.INFO, classname, "loadDefaultKey", MessageKeys.LOAD_KEY_FILE_FROM, new Object[] {signingKeyFile});
> }
> "signingKeyFile" is the variable that will be inserted into the "couldNotLoadKeyFile" template text in the resource.properties, replacing {0} below. The number 0 is the array index of the variable of new Object[] {signingKeyFile}, you can add as many arguments to the the array as needed, then reference them using their indexes in the text template.
> couldNotLoadKeyFile=Couldn't load key file {0}
>     * The localized text in the resouce.properties is a 1 liner, to add a new line, just add \n at the end of the sentence. Other text formatting is in similar fashion. Here's an example of logging text in the resource.properties file with newline feed
> couldNotLoadSignedKey=Couldn''t load OAuth signing key. To create a key, run:\n openssl req -newkey rsa:1024 -days 365 -nodes -x509 -keyout testkey.pem \\\n -out testkey.pem -subj '/CN=mytestkey'\n openssl pkcs8 -in testkey.pem -out oauthkey.pem -topk8 -nocrypt -outform PEM\n\n Then edit shindig.properties and add these lines:\n {0} =<path-to-oauthkey.pem>\n {1} =mykey\n
> I will commit this patch to trunk by end of next week if no objection.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.