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

io.github.eocqrs.xfake.Logged Maven / Gradle / Ivy

The newest version!
package io.github.eocqrs.xfake;

import com.jcabi.log.Logger;
import com.jcabi.xml.XML;
import org.xembly.Directive;

import java.util.logging.Level;

/**
 * Logging decorator for {@link FkStorage}.
 *
 * @author Aliaksei Bialiauski ([email protected])
 * @since 0.1.2
 */
public final class Logged implements FkStorage {

  /**
   * Origin Storage to decorate.
   */
  private final FkStorage origin;
  /**
   * Logging level.
   */
  private final Level level;

  /**
   * Ctor.
   *
   * @param orgn Storage
   * @param lvl  Logging level
   */
  public Logged(final FkStorage orgn, final Level lvl) {
    this.origin = orgn;
    this.level = lvl;
  }

  @Override
  public XML xml() throws Exception {
    Logger.log(this.level, this, "#xml method was called");
    final XML xml = this.origin.xml();
    Logger.log(this.level, this, "XML loaded: %s", xml);
    return xml;
  }

  @Override
  public void apply(final Iterable dirs) throws Exception {
    Logger.log(this.level, this, "#apply(%s) was called", dirs);
    this.origin.apply(dirs);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy