/** * Returns a logging rule with the given threshold. */ @Pure public static @Nonnull LoggingRule with(@Nonnull Level threshold) { return new LoggingRule(threshold, null, null, null); }
/** * Returns a logging rule with the given threshold, caller prefix, thread prefix and message regex. */ @Pure public static @Nonnull LoggingRule with(@Nonnull Level threshold, @Nullable String callerPrefix, @Nullable String threadPrefix, @Nullable String messageRegex) { return new LoggingRule(threshold, callerPrefix, threadPrefix, messageRegex); }
/** * Returns a logging rule with the given threshold and caller prefix. */ @Pure public static @Nonnull LoggingRule with(@Nonnull Level threshold, @Nullable String callerPrefix) { return new LoggingRule(threshold, callerPrefix, null, null); }
/** * Returns a logging rule with the given threshold, caller prefix and thread prefix. */ @Pure public static @Nonnull LoggingRule with(@Nonnull Level threshold, @Nullable String callerPrefix, @Nullable String threadPrefix) { return new LoggingRule(threshold, callerPrefix, threadPrefix, null); }
/** * Decodes the given line and returns the corresponding rule. * * @throws IllegalArgumentException if a rule has an invalid level. */ @Pure public static @Nonnull LoggingRule decode(@Nonnull String line) throws IllegalArgumentException { final @Nonnull @NonNullableElements String[] tokens = line.split(";", 4); final @Nonnull Level threshold = Level.valueOf(tokens[0].trim().toUpperCase()); final @Nullable String callerPrefix = getNonEmpty(tokens, 1); final @Nullable String threadPrefix = getNonEmpty(tokens, 2); final @Nullable String messageRegex = getNonEmpty(tokens, 3); return new LoggingRule(threshold, callerPrefix, threadPrefix, messageRegex); }