Tabnine Logo
MonolineFormatter.levelWidth
Code IndexAdd Tabnine to your IDE (free)

How to use
levelWidth
method
in
org.apache.sis.util.logging.MonolineFormatter

Best Java code snippets using org.apache.sis.util.logging.MonolineFormatter.levelWidth (Showing top 4 results out of 315)

origin: apache/sis

/**
 * Formats the given expected string to a format matching the current locale setting.
 * The given string shall use tabulation before each line of the message.
 */
private static String localize(final Level level, final String expected) {
  final String levelToReplace = level.getName();
  final String levelLocalized = level.getLocalizedName();
  assertTrue(expected, expected.startsWith(levelToReplace));
  final int margin = MonolineFormatter.levelWidth(null);
  final StringBuilder buffer = new StringBuilder(expected.length() + 40)
      .append(levelLocalized)
      .append(CharSequences.spaces(margin - levelLocalized.length()))
      .append(expected, levelToReplace.length() + 1, expected.length());      // +1 is for skipping '\t'.
  final String spaces = MonolineFormatter.CONTINUATION_MARK
            + CharSequences.spaces(margin - 1).toString();
  int positionOfLast = -1;
  for (int i=margin; (i=buffer.indexOf("\n\t", i)) >= 0; i += margin) {
    buffer.replace(positionOfLast = ++i, i+1, spaces);                          // Replace only tabulation, leave new line.
  }
  if (positionOfLast >= 0) {
    buffer.setCharAt(positionOfLast, MonolineFormatter.CONTINUATION_END);
  }
  return buffer.toString();
}
origin: apache/sis

/**
 * Tests {@link MonolineFormatter#levelWidth(Level)}.
 */
@Test
public void testlevelWidth() {
  final String severe = Level.SEVERE.getLocalizedName();
  assertEquals(severe, severe.length(), MonolineFormatter.levelWidth(Level.SEVERE));
  final String warning = Level.WARNING.getLocalizedName();
  assertEquals(warning, StrictMath.max(severe.length(), warning.length()),
      MonolineFormatter.levelWidth(Level.WARNING));
}
origin: org.apache.sis.core/sis-utility

levelWidth = levelWidth((handler != null) ? handler.getLevel() : null);
origin: apache/sis

levelWidth = levelWidth((handler != null) ? handler.getLevel() : null);
org.apache.sis.util.loggingMonolineFormatterlevelWidth

Javadoc

The minimum amount of characters to use for writing logging level before the message. If the logging level is shorter, remaining characters will be padded with spaces. This is used in order to align the messages.

Popular methods of MonolineFormatter

  • install
    Installs a MonolineFormatter for the specified logger, or returns the existing instance if any. This
  • <init>
    Constructs a default MonolineFormatter.Auto-configuration from the handler Formatters are often ass
  • colorAt
    Gets the color for the given level. If there is no explicit color for the given level, returns the c
  • colors
    Returns the #colors map, creating it if needed.
  • format
    Formats the given log record and return the formatted string. See the class javadoc for information
  • formatMessage
    Returns the localized message from the given log record. First this method gets the LogRecord#getMes
  • more
    Formats the number of stack trace elements that where skipped.
  • printAbridged
    Prints an abridged stack trace. This method is invoked when the record is logged at at low logging l
  • resetLevelColors
    Resets the colors setting to its default value. * If enabled is true, then this method defines a
  • setHeader
    Sets the string to write on the left side of the first line of every log records.
  • setSourceFormat
    Sets the format for displaying the source, or hides the source field. The given format can be any of
  • setTimeFormat
    Sets the format for elapsed time, or hides the time field. The pattern must matches the format speci
  • setSourceFormat,
  • setTimeFormat,
  • sourceFormat,
  • timeFormat

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • getSystemService (Context)
  • onCreateOptionsMenu (Activity)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now