From cc06b83c11606ed6089456ca3929b530bc8a20ec Mon Sep 17 00:00:00 2001 From: rjenkinsjr Date: Thu, 31 Mar 2016 19:50:04 -0400 Subject: [PATCH] showLogName overrides showShortLogName --- .../slf4j/impl/BukkitPluginLoggerAdapter.java | 24 +++++++++++-------- src/site/markdown/index.md | 16 ++++++++----- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/slf4j/impl/BukkitPluginLoggerAdapter.java b/src/main/java/org/slf4j/impl/BukkitPluginLoggerAdapter.java index 3bc4ee4..2f36a9c 100644 --- a/src/main/java/org/slf4j/impl/BukkitPluginLoggerAdapter.java +++ b/src/main/java/org/slf4j/impl/BukkitPluginLoggerAdapter.java @@ -98,14 +98,18 @@ import org.yaml.snakeyaml.Yaml; * defaults to false. * *
  • slf4j.showLogName - Set to true if you want the - * logger instance name to be included in output messages. If unspecified or - * given any other value, defaults to false.
  • + * logger instance name (wrapped in curly braces) to be included in output + * messages. If unspecified or given any other value, defaults to + * false. If this option is true, it overrides + * slf4j.showShortLogName. * *
  • slf4j.showShortLogName - Set to true if you - * want the logger instance's short name to be included in output messages. The - * short name is equal to the full name with every dot-separated portion of the - * full name (except the last portion) truncated to its first character. If - * unspecified or given any other value, defaults to true.
  • + * want the logger instance's short name (wrapped in curly braces) to be + * included in output messages. The short name is equal to the full name with + * every dot-separated portion of the full name (except the last portion) + * truncated to its first character. If unspecified or given any other value, + * defaults to true. This option is ignored if + * slf4j.showLogName is true. * * *

    @@ -810,13 +814,13 @@ public final class BukkitPluginLoggerAdapter extends MarkerIgnoringBase { } // Append the name of the log instance if so configured - if (BukkitPluginLoggerAdapter.CONFIG_VALUE_SHOW_SHORT_LOG_NAME) { + if (BukkitPluginLoggerAdapter.CONFIG_VALUE_SHOW_LOG_NAME) { + buf.append('{').append(this.name).append("} "); + } else if (BukkitPluginLoggerAdapter.CONFIG_VALUE_SHOW_SHORT_LOG_NAME) { if (this.shortLogName == null) { this.shortLogName = this.computeShortName(); } - buf.append(String.valueOf(this.shortLogName)).append(" - "); - } else if (BukkitPluginLoggerAdapter.CONFIG_VALUE_SHOW_LOG_NAME) { - buf.append(String.valueOf(this.name)).append(" - "); + buf.append('{').append(this.shortLogName).append("} "); } // Append the message diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index e6a5da3..15eccf1 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -55,16 +55,20 @@ slf4j: # If not specified or given an invalid value, defaults to "false". showThreadName: false - # Shows the full logger name (e.g. "info.ronjenkins.bukkit.MyPlugin"). + # Shows the full logger name (e.g. "info.ronjenkins.bukkit.MyPlugin"), + # wrapped in curly braces. # - # If not specified or given an invalid value, defaults to "false". + # If not specified or given an invalid value, defaults to "false". If true, + # this overrides "slf4j.showShortLogName". showLogName: false - # Shows the short logger name, which is the short Java package name format - # (e.g. a logger named "info.ronjenkins.bukkit.MyPlugin" would have a short - # name of "i.r.b.MyPlugin". + # Shows the short logger name, wrapped in curly braces. The short logger name + # is the short Java package name format (e.g. a logger named + # "info.ronjenkins.bukkit.MyPlugin" would have a short name of + # "i.r.b.MyPlugin"). # - # If not specified or given an invalid value, defaults to "true". + # If not specified or given an invalid value, defaults to "true". If + # "slf4j.showLogName" is true, this option is ignored. showShortLogName: true # This section controls logging levels for individual loggers.