11package java .util .logging
22
3+ import java .lang .StringBuilder
4+
35abstract class Formatter protected () {
46
57 def format (record : LogRecord ): String
@@ -17,7 +19,7 @@ abstract class Formatter protected () {
1719 // Instead we'll do simple text replacement, very imperative
1820 var msgAccumulator = new StringBuilder ()
1921 var inParam = false
20- var paramInFlight : StringBuilder = null
22+ var paramInFlight : StringBuilder = null
2123 var substitutionFailure = false // track failure to break the loop
2224 var i = 0
2325
@@ -31,13 +33,13 @@ abstract class Formatter protected () {
3133 paramInFlight = new StringBuilder ()
3234 } else if (inParam && currentChar != '}' ) {
3335 // accumulate the param
34- paramInFlight += currentChar
36+ paramInFlight.append( currentChar)
3537 } else if (currentChar == '}' ) {
3638 // end of param, replace placeholder by value if possible
3739 inParam = false
3840 val (failed, replacement) = {
3941 try {
40- val index = paramInFlight.toInt
42+ val index = paramInFlight.toString(). toInt
4143 if (index >= 0 && index < params.length) {
4244 (false , params(index).toString)
4345 } else if (index > 0 ) {
@@ -55,15 +57,17 @@ abstract class Formatter protected () {
5557
5658 // The JVM will fail if e.g. there are bogus params and would not replace
5759 // any parameter
58- if (failed) substitutionFailure = failed
59- else msgAccumulator ++= replacement
60+ if (failed)
61+ substitutionFailure = failed
62+ else
63+ msgAccumulator.append(replacement)
6064 } else {
61- msgAccumulator += currentChar
65+ msgAccumulator.append( currentChar)
6266 }
6367 }
6468
6569 if (substitutionFailure || inParam) msg
66- else msgAccumulator.result ()
70+ else msgAccumulator.toString ()
6771 } else {
6872 msg
6973 }
0 commit comments