Message argument descriptors

Specifying a message is disclosed. A message and one or more arguments of the message are specified. An argument type is associating with at least one of the one or more arguments. Processing a message is disclosed. A message is identified to be transformed. The message is transformed at least in part by using an argument type associated with an argument of the message.

BACKGROUND OF THE INVENTION

A message (e.g., status message, error message, log entry, text data for display to a user, etc.) is often specified by a programmer in program code. Specifying the text message typically includes specifying one or more arguments of the message that can be used to dynamic determine at least a portion of the message during runtime of the program. For example, a program variable is specified as an argument of the message, and the content of the variable is included in a generated output of the message such as a log file or output text to be displayed to a user. Processing can be performed using the specification of the message in program code and/or the generated message output. Often the processing requires information about arguments of the message. However, the generated message output does not typically include data about the arguments of the message. For the specification of the message in program code, although the programming language of the program code can be used to specify a data type (e.g., integer, float, string, etc.) associated with the message argument, often the processing performed using the program code message specification requires information about message arguments that cannot be determined from the associated data type information. Therefore there is a need for a way to determine additional information about an argument of a program code message.

DETAILED DESCRIPTION

Associating an argument type with an argument of a message is disclosed. In some embodiments, the message includes text specified in program code for output. When the message of the program code is outputted, the message output includes contents of one or more arguments of the message at the time the message was outputted, and the argument contents are associated with one or more corresponding argument types. Using the associated arguments types, the message specification and/or the message output can be modified, searched, transformed, categorized, and/or otherwise processed. For example, in rendering the message for a viewer that is not authorized to view private contents of the message, contents of message arguments associated with an argument type that indicates the associated content as private are obfuscated before the message is rendered for display.

FIG. 1is a block diagram illustrating an embodiment of a program code message environment. Message generator102generates a message output. In some embodiments, message generator102executes at least a portion of program code that includes a specification of a message to be generated. For example, using a syntax of a programming language, a programmer specifies the message for output when a program/process of the program code is executed. The message output generated by generator102is stored in message storage104. For example, the message output is stored in a log file in storage104. In some embodiments, the message output is stored in storage104not as an end destination but as a temporary destination before the generated message output is used to render the message in a desired format. For example, an error message to be displayed to a user is temporarily stored in message storage104before being sent to be rendered for a viewer in a desired language. In some embodiments, the message output includes contents of one or more message arguments at the time the message output was generated. For example, contents of one or more variables used as message arguments are stored in the message output. The message argument contents stored in the message output are not substituted in a message form of the message until the message is rendered.

Message renderer106renders a message output stored in message storage104. In some embodiments, message renderer106renders the message output in response to a request for the message output to be viewed. Rendering the message includes displaying the message in a determined context. Message catalog108includes data that can be used to render a message. In some embodiments, foreign language translations of a message are stored in message catalog108. A plurality of message catalogs may be used. In the example shown, message catalog108is used at least in part to render the message. Message catalog108is optional. Message viewer110is to view the rendered message. Examples of message viewer110include a log viewer, a message dialog, and any other interface that can be used to view a rendered message.

Program code processor112processes program code to identify and manage messages defined in the program code. For example, one or more messages specified in program code are identified and added to message catalog108by processor112. Message reviewer114reviews messages stored in message catalog108. For example, the messages are reviewed for grammar, spelling, readability, correctness, and/or compliance. Message translator116translates one or more messages stored in catalog108. The translated messages may be stored in catalog108, another message catalog, and/or in another destination. In various embodiments, program code processor112, message reviewer114, and/or message translator116are optional.

Processing can be performed using the specification of the message in program code and/or the message output. Since the message includes one or more arguments that are determined at runtime, uncertainty about the function and/or semantic role of message arguments makes some desired processing difficult. For example, the ability to recognize the meaning of certain parts of a text is useful during language translation where different semantic meaning of a word can result in different translation of the same text in the same language. If semantic meaning can be provided about message arguments to be substituted in the message text, the translation of the message can be improved.

FIG. 2is a flowchart illustrating an embodiment of a process for associating an argument type with a message form. At202, a message form and one or more arguments, if any, of the message are specified. Specifying the message form and arguments is included in specifying a message in program code. An example of the program code includes code generated using a function-oriented programming language such as the C programming language. The message form defines the content and/or structure of the message. For example, the message form defines the text to be rendered along with contents of one or more message argument variables, if any. The one or more arguments of the message form allow contents of the arguments to be inserted into an output generated using the message form. For example, to display “Hello” with a name of a person dynamically obtained from a program code variable, the following C programming language statement can be used: printf(“Hello % s”, name). “Hello % s” is the message form and “name” is the argument of the message. When the printf statement is executed, contents of the “name” variable is substituted for the “% s” in the message form.

At204, an argument type is associated with at least one argument of the one or more arguments. In some embodiments, more than one argument type is or may be associated with a single argument. In some embodiments, associating the argument type includes specifying in program code an argument type identifier for each of the one or more arguments. In some embodiments, the argument of the message is associated with a programming language data type identifier in addition to the argument type identifier. For example, a variable specified as an argument of the message is associated with the data type identifier when the variable is instantiated in program code. In some embodiments, the argument type identifier identifies one of a plurality of predetermined argument types. For example, in a function-oriented programming language such as the C programming language, message argument type identifiers are specified in some embodiments by “#define” as shown below.

In the example above, a message argument associated with the “AD_STBUF” argument type identifier includes a complete message. This allows a message to be recursively nested as an argument in another message. In some embodiments, a data structure such as a struct of the C programming language associates the message arguments with the message argument type identifier. A message argument identifier may be assigned manually and/or automatically. For example, a programmer identifies specifies the argument type identifier when specifying the message in program code. In another example, the message argument type for a message argument is determined automatically at least in part by examining the content of the message argument.

FIG. 3is flowchart illustrating an embodiment of a process for processing a message. At302, a message to be processed is identified. In some embodiments, identifying the message includes identifying message data in program code and/or in a message catalog such as catalog108ofFIG. 1. For example, the message to be processed is identified at least in part by using an identifier of the message. The message identifier can be used to obtain from a message catalog data associated with the message. In some embodiments, identifying the message includes identifying a message output. In some embodiments, the message output includes contents of one or more message arguments at the time the message output was generated. A respective message argument identifier and message argument type identifier are associated with each included message argument content.

At304, the message is processed at least in part by using an argument type associated with an argument of the message. In some embodiments, processing the message includes performing one or more of the following: translating at least a portion of the message using an argument type, searching at least a portion of the message using an argument type, and transforming at least a portion of the message using an argument type.

For example, when translating a message form of the message to another language, it is difficult to determine what type of data will be substituted in as the message argument. If no additional information about the message argument is available, the translation of the message form may not be grammatically correct. The message argument type can provide additional semantic information about the message argument to create a better translation of the message form. As an example, in the C programming language, if the message form to translate is “% s: % s % s % s”, a foreign language translator has no idea on what semantic role (i.e. noun, verb, adjective, etc) each % s represents without an associated message argument type identifier. Depending on the role, the order of the % s may be different for different languages. For each % s message argument, there exists an associated message argument type identifier (e.g. identifiers that that identify the first and second % s are nouns, the third % s is a verb, and the last % s is an status). The translator can make informed per-language adjustments to the translated message form using the message argument type information.

In another example, the message is outputted in a log. The log may contain large amount of other messages, and a viewer may desire to filter the log to only view messages of interest. By using message argument type identifier associated with the messages in the output, context-specific search is possible. A text search only within message argument contents associated with a specified argument type can be performed. For example, instead of finding all instances of “Server2,” a user can search for instances of “Server2” only when used as a device host (e.g., associated with device host message argument type) or only when used as a data source (e.g., associated with data source message argument type).

In another example, the message argument type identifier is used to validate the message during source coding and runtime. The message can be checked to determine whether the message follows a required pattern of one or more message argument types and/or includes a not allowed pattern of one or more message argument types.

FIG. 4is a flowchart illustrating an embodiment of a process for rendering a message. In some embodiments, the process ofFIG. 4is included 304 ofFIG. 3. At402, an identification of an argument type associated with message data to be modified when rendering a message is received. In some embodiments, the message data includes message argument content included in a message output of a message specified in program code. At404, the message is rendered including by modifying the message data that are associated with the identified argument type. Rendering the message includes displaying at least a portion of the message to a viewer. In various embodiments, modifying the message data includes translating, obfuscating, replacing, adding, and/or removing content of the message data.

For example, if contents of specific message arguments are desired to be hidden to a non-secure third party, sensitive data such as host name and network address (e.g., content associated with host name argument type and network address argument type) can be scrambled or aliased so that it is obfuscated when rendered for display. In another example, when the message argument content is a time value, different locales may wish to view the time value in different formats. One locale may desire to view the time in a MM/DD/YY format, whereas another locale may wish to view the time in a DD/MM/YY format. By using an argument type to determine that a message argument content is associated with a time value, the content can be translated into a desired time format of the viewer.