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

com.medallia.word2vec.util.NDC Maven / Gradle / Ivy

There is a newer version: 0.10.3
Show newest version
package com.medallia.word2vec.util;


/** Helper to create {@link org.apache.log4j.NDC} for nested diagnostic contexts */
public class NDC implements AC {
	private final int size;

	/** Push all the contexts given and pop them when auto-closed */
	public static NDC push(String... context) {
		return new NDC(context);
	}

	/** Construct an {@link AutoCloseable} {@link NDC} with the given contexts */
	private NDC(String... context) {
		for (String c : context) {
			org.apache.log4j.NDC.push("[" + c + "]");
		}
		this.size = context.length;
	}

	@Override
	public void close() {
		for (int i = 0; i < size; i++) {
			org.apache.log4j.NDC.pop();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy