Java slf4j Logger findMarker(Marker marker, String name)

Here you can find the source of findMarker(Marker marker, String name)

Description

Find the marker with the given name in the given marker or its references

License

Open Source License

Parameter

Parameter Description
marker the marker to search
name the name of the marker to find

Return

the found marker or null

Declaration

public static Marker findMarker(Marker marker, String name) 

Method Source Code

//package com.java2s;
// it and/or modify it under the terms of the GNU Lesser General Public License

import java.util.Iterator;
import org.slf4j.Marker;

public class Main {
    /**/*  w ww.j av a2  s. c om*/
     * Find the marker with the given name in the given marker or its references
     * 
     * @param marker the marker to search
     * @param name the name of the marker to find
     * 
     * @return the found marker or <code>null</code>
     */
    public static Marker findMarker(Marker marker, String name) {
        if (marker == null) {
            return null;
        }

        if (marker.getName().equals(name)) {
            return marker;
        } else if (marker.hasReferences()) {
            Iterator<?> refs = marker.iterator();
            while (refs.hasNext()) {
                Object ref = refs.next();
                if (ref instanceof Marker) {
                    Marker result = findMarker((Marker) ref, name);
                    if (result != null) {
                        return result;
                    }
                }
            }

            return null;
        } else {
            return null;
        }
    }
}

Related

  1. error(Logger logger, Exception e)
  2. error(String errorMessage, Throwable e)
  3. error(String msg, Throwable e)
  4. ExecptionLog(Logger log, String msg, Throwable e)
  5. extractValue(String var)
  6. format(final String pattern, final @Nullable Object... arguments)
  7. format(String format, Object... args)
  8. format(String messagePattern, Object... args)
  9. get(Class clazz)