[fix] Use string concatenation in delegated function for logging

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2021-11-07 11:45:29 +01:00
parent 2ece273148
commit d726312341
2 changed files with 4 additions and 4 deletions

View File

@ -191,7 +191,7 @@ public final class ConsoleApplication implements ICommandProvider {
args = GCLCConstants.splitCommand(cmd); args = GCLCConstants.splitCommand(cmd);
} catch (final CommandParsingException e) { } catch (final CommandParsingException e) {
out.println("Command line cannot be parsed"); //$NON-NLS-1$ out.println("Command line cannot be parsed"); //$NON-NLS-1$
LOGGER.log(Level.FINE, "Invalid user command " + cmd, e); //$NON-NLS-1$ LOGGER.log(Level.FINE, e, () -> "Invalid user command " + cmd); //$NON-NLS-1$
return; return;
} }
if (!args.isEmpty()) { if (!args.isEmpty()) {
@ -199,7 +199,7 @@ public final class ConsoleApplication implements ICommandProvider {
executeSub(out, in, args.get(0), executeSub(out, in, args.get(0),
Arrays.copyOfRange(args.toArray(new String[0]), 1, args.size())); Arrays.copyOfRange(args.toArray(new String[0]), 1, args.size()));
} catch (final CommandRunException e) { } catch (final CommandRunException e) {
LOGGER.log(Level.FINE, "Command failed: " + cmd, e); //$NON-NLS-1$ LOGGER.log(Level.FINE, e, () -> "Command failed: " + cmd); //$NON-NLS-1$
out.println(Messages.getString("ConsoleApplication.cmd.failed", cmd)); //$NON-NLS-1$ out.println(Messages.getString("ConsoleApplication.cmd.failed", cmd)); //$NON-NLS-1$
out.println(e.getLocalizedMessage()); out.println(e.getLocalizedMessage());
if (e.getType() == CommandRunExceptionType.USAGE) { if (e.getType() == CommandRunExceptionType.USAGE) {

View File

@ -105,8 +105,8 @@ public final class Messages {
try { try {
return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args); return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args);
} catch (final MissingResourceException e) { } catch (final MissingResourceException e) {
LOGGER.log(Level.WARNING, LOGGER.log(Level.WARNING, e,
"Unrecognized internationalization message key: " + key, e); //$NON-NLS-1$ () -> "Unrecognized internationalization message key: " + key); //$NON-NLS-1$
return '!' + key + '!'; return '!' + key + '!';
} }
} }