/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software License
 * version 1.1, a copy of which has been included  with this distribution in
 * the LICENSE.APL file.
 */

package org.apache.log4j.varia;

import org.apache.log4j.spi.Filter;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.LocationInfo;

/**
  This is pass-thru filter that simply calls
  {@link LoggingEvent#getLocationInformation} method of every LoggingEvent
  that is sent to it via the {@link Filter#decide} method. After calling the method,
  it returns {@link Filter#NEUTRAL} to send the event to the next filter.
  
  This is useful to use in conjunction with other filters (particularly
  filters that descent from {@link GenericMatchFilter}) to set the
  {@link LocationInfo} for some events, and not others.
  
  @author Mark Womack
*/
public abstract class SetLocationInfoFilter extends Filter {

  /**
    Sets the LocationInfo for the event and returns {@link Filter#NEUTRAL}
    to pass the event to the next filter. */
  public
  int decide(LoggingEvent event) {
    event.getLocationInformation();
    return Filter.NEUTRAL;
  }
}
