To analyse the existing log statement in source code, Log4E uses the accordingly template (defined in Log4E > Templates preference page)
Example 1
Assume the existing log statement is:
- debug("otherMethod() - starttext");
Therefore the accordingly template is:
- debug("${enclosing_method}${delimiter}${message}${delimiter}${return_value}")
Log4E makes a guess to map the tokens to the right variables. In this case, assuming that ${delimiter}=" - ", everything is alright. The mapping would be:
${enclosing_method}="otherMethod()"
${message}="starttext"
${return_value}=""
Only the ${message} is kept. Everything else will be replaced with the computed values. The result would be:
- debug("myMethod() - starttext");
To compute the right tokens Log4E uses the delimiter. If the delimiter, defined in the <a href="/preferences.html#Format">"Log4E > Format"</a> preferences, is different to delimiter used in the source code, Log4E won't be able to extract the user message.
Example 2
Assume the existing log statement is:
- debug("otherMethod() : starttext");
Therefore the accordingly template is:
- debug("${enclosing_method}${delimiter}${message}${delimiter}${return_value}")
In this case, assuming that ${delimiter}=" - ", the mapping would be:
${enclosing_method}="otherMethod() : starttext"
${message}=""
${return_value}=""
When Log4E recognizes that the ${message} is empty it will pop up a warning. The user can choose from there if he or she wants to start the Preview Wizard before confirming the changes.
If confirmed by user the result would be:
- debug("myMethod()");
Note that the logger statement "error("otherMethod()", e)" generated by Log4E doesn't have a message by default. Therefore Log4E will pop up a warning when performing modification even if the message must be empty in this case.
Example 3 (worst case)
Assume the existing log statement is:
- debug("starttext - otherMethod()");
Therefore the accordingly template is:
- debug("${enclosing_method}${delimiter}${message}${delimiter}${return_value}")
In this case, assuming that ${delimiter}=" - ", the mapping would be:
${enclosing_method}="starttext"
${message}="otherMethod()"
${return_value}=""
This is the worst case. Log4E does not recognize that the mapping is wrong because ${message} is not empty. Log4E would delete the exisitng message without a warning:
- debug("myMethod() - otherMethod()");
Abstract
The modification task is best used with Log4E generated log statements!