Codota Logo
net.digitalid.utility.logging.filter
Code IndexAdd Codota to your IDE (free)

How to use net.digitalid.utility.logging.filter

Best Java code snippets using net.digitalid.utility.logging.filter (Showing top 16 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: net.digitalid.utility/utility-logging

/**
 * Returns a logging rule with the given threshold.
 */
@Pure
public static @Nonnull LoggingRule with(@Nonnull Level threshold) {
  return new LoggingRule(threshold, null, null, null);
}

origin: net.digitalid.utility/utility-logging

/**
 * Returns a logging filter with the given threshold.
 */
@Pure
public static @Nonnull LevelBasedLoggingFilter with(@Nonnull Level threshold) {
  return new LevelBasedLoggingFilter(threshold);
}

origin: net.digitalid.utility/utility-testing

/**
 * Initializes the logging filter.
 */
@PureWithSideEffects
@Initialize(target = LoggingFilter.class)
public static void initializeLoggingFilter() {
  final @Nonnull @Absolute File projectDirectory = new File("").getAbsoluteFile();
  final @Nonnull String callerPrefix = "net.digitalid." + projectDirectory.getParentFile().getName() + "." + projectDirectory.getName();
  LoggingFilter.filter.set(ConfigurationBasedLoggingFilter.with(Files.relativeToWorkingDirectory("config/TestingLogging.conf"), LoggingRule.with(Level.VERBOSE, callerPrefix + "."), LoggingRule.with(Level.INFORMATION)));
}

origin: net.digitalid.utility/utility-logging

/**
 * 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);
}

origin: net.digitalid.utility/utility-logging

protected ConfigurationBasedLoggingFilter(@Nonnull File file, @Nonnull @NonNullableElements LoggingRule... defaultRules) throws IllegalArgumentException {
  super(defaultRules);
  
  this.file = file;
  if (file.exists()) {
    reload();
  } else {
    Files.write(comments.combine(getRules().map(LoggingRule::encode)), file);
  }
}

origin: net.digitalid.utility/utility-logging

/**
 * Logs the given message and throwable if the configured filter accepts them.
 * Each dollar sign in the message is replaced with the corresponding argument.
 */
@Impure
public static void log(@Nonnull Level level, @Nonnull CharSequence message, @Nullable Throwable throwable, @NonCaptured @Unmodified @Nonnull @NullableElements Object... arguments) {
  final @Nonnull LoggingFilter filter = LoggingFilter.filter.get();
  if (filter.isPotentiallyLogged(level)) {
    final @Nonnull String caller = Caller.get();
    final @Nonnull String thread = Thread.currentThread().getName();
    final @Nonnull String originalMessage = message.toString();
    final boolean addNoPeriod = originalMessage.endsWith(".") || originalMessage.endsWith(":") || originalMessage.endsWith("\n");
    final @Nonnull String formattedMessage = Strings.format(originalMessage, arguments) + (addNoPeriod ? "" : ".");
    if (filter.isLogged(level, caller, thread, formattedMessage, throwable)) { logger.get().log(level, caller, thread, formattedMessage, throwable); }
  }
}

origin: net.digitalid.utility/utility-logging

/**
 * Returns a logging filter with the given configuration file and default rules.
 * 
 * @throws IllegalArgumentException if a rule has an invalid level.
 */
@Pure
public static @Nonnull ConfigurationBasedLoggingFilter with(@Nonnull File file, @Nonnull @NonNullableElements LoggingRule... defaultRules) throws IllegalArgumentException {
  return new ConfigurationBasedLoggingFilter(file, defaultRules);
}

origin: net.digitalid.utility/utility-logging

@Pure
@Override
public boolean isLogged(@Nonnull Level level, @Nonnull String caller, @Nonnull String thread, @Nonnull String message, @Nullable Throwable throwable) {
  return rules.matchAny(rule -> rule.accepts(level, caller, thread, message));
}

origin: net.digitalid.utility/utility-logging

/**
 * Returns a logging filter with the given rules.
 */
@Pure
public static @Nonnull RuleBasedLoggingFilter with(@Nonnull @NonNullableElements LoggingRule... rules) {
  return new RuleBasedLoggingFilter(rules);
}

origin: net.digitalid.utility/utility-logging

@Pure
@Override
public boolean isPotentiallyLogged(@Nonnull Level level) {
  return rules.matchAny(rule -> level.getValue() >= rule.getThreshold().getValue());
}

origin: net.digitalid.utility/utility-logging

/**
 * Reloads the logging rules from the configuration file.
 * 
 * @throws IllegalArgumentException if a rule has an invalid level.
 */
@Impure
public void reload() throws IllegalArgumentException {
  setRules(Files.readNonCommentNonEmptyTrimmedLines(file).map(LoggingRule::decode).evaluate());
}

origin: net.digitalid.utility/utility-processing

/**
 * Initializes the output file of the logger with the given name.
 */
@Impure
public static void initialize(@Nonnull String name) throws IllegalArgumentException, FileNotFoundException {
  Caller.index.set(6);
  Version.string.set("0.7");
  LoggingFilter.filter.set(ConfigurationBasedLoggingFilter.with(Files.relativeToWorkingDirectory("config/" + name + ".conf"), LoggingRule.with(Level.INFORMATION)));
  Logger.logger.set(FileLogger.with(Files.relativeToWorkingDirectory("target/processor-logs/" + name + ".log")));
}

origin: net.digitalid.utility/utility-logging

/**
 * 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);
}

origin: net.digitalid.utility/utility-initializer

/**
 * Initializes the logging filter with a configuration-based logging filter.
 * 
 * @throws IllegalArgumentException if a rule has an invalid level.
 */
@PureWithSideEffects
@Initialize(target = LoggingFilter.class, dependencies = Files.class)
public static void initializeLoggingFilter() throws IllegalArgumentException {
  if (LoggingFilter.filter.get() instanceof LevelBasedLoggingFilter) {
    LoggingFilter.filter.set(ConfigurationBasedLoggingFilter.with(Files.relativeToConfigurationDirectory("configs/logging.conf"), LoggingRule.with(Level.INFORMATION)));
    Log.verbose("Replaced the default level-based logging filter with a configuration-based logging filter.");
  } else {
    Log.verbose("Did not replace the non-default logging filter with a configuration-based logging filter.");
  }
}

origin: net.digitalid.utility/utility-logging

/**
 * 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);
}

origin: net.digitalid.utility/utility-logging

/**
 * 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);
}

net.digitalid.utility.logging.filter

Most used classes

  • ConfigurationBasedLoggingFilter
    This logging filter loads its rules from a configuration file.
  • LoggingRule
    A logging rule defines which messages are accepted and thus logged.
  • LevelBasedLoggingFilter
    This logging filter accepts all messages at and above the given threshold.
  • LoggingFilter
    Instances of this class are used to filter log messages.
  • RuleBasedLoggingFilter
    This logging filter accepts a message if any of its rules matches.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now