All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.triceo.splitlog.DefaultLogWatchBuilder Maven / Gradle / Ivy

Go to download

These are the core parts of splitlog. This is where the implementations of the public APIs live. Classes from this package come with no API stability guarantees.

There is a newer version: 1.7.2
Show newest version
package com.github.triceo.splitlog;

import org.slf4j.Logger;

import com.github.triceo.splitlog.api.Follower;
import com.github.triceo.splitlog.api.LogWatch;
import com.github.triceo.splitlog.api.LogWatchBuilder;
import com.github.triceo.splitlog.api.TailSplitter;
import com.github.triceo.splitlog.conditions.AllFollowerMessagesAcceptingCondition;
import com.github.triceo.splitlog.conditions.SplitlogMessagesRejectingCondition;
import com.github.triceo.splitlog.logging.SplitlogLoggerFactory;
import com.github.triceo.splitlog.splitters.SimpleTailSplitter;

/**
 * Prepares an instance of {@link LogWatch}. Unless overriden by the user, the
 * instance will have the following properties:
 *
 * 
*
Default gating condition
*
{@link SplitlogMessagesRejectingCondition}.
*
Default storage condition
*
{@link AllFollowerMessagesAcceptingCondition}.
*
* */ final public class DefaultLogWatchBuilder extends LogWatchBuilder { private static final Logger LOGGER = SplitlogLoggerFactory.getLogger(DefaultLogWatchBuilder.class); public DefaultLogWatchBuilder() { super(); this.withGateCondition(SplitlogMessagesRejectingCondition.INSTANCE); this.withStorageCondition(AllFollowerMessagesAcceptingCondition.INSTANCE); } @Override public LogWatch build() { return this.buildWith(new SimpleTailSplitter()); } @Override public Follower buildFollowing() { return this.buildFollowingWith(new SimpleTailSplitter()); } @Override public Follower buildFollowingWith(final TailSplitter splitter) { if (splitter == null) { throw new IllegalArgumentException("A splitter must be provided."); } return this.buildWith(splitter).startFollowing(); } @Override public LogWatch buildWith(final TailSplitter splitter) { if (splitter == null) { throw new IllegalArgumentException("A splitter must be provided."); } else if ((splitter instanceof SimpleTailSplitter) && (this.getGateCondition() instanceof SplitlogMessagesRejectingCondition)) { DefaultLogWatchBuilder.LOGGER .warn("Using default TailSplitter with default gating condition. All messages will pass through gate, as the TailSplitter will not provide all the necessary information."); } final LogWatch watch = new DefaultLogWatch(this, splitter); if (this.willBeStarted()) { watch.start(); } else { DefaultLogWatchBuilder.LOGGER .info("LogWatch will not be started automatically. To receive messages, you need to start it yourself."); } return watch; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy