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

org.hibernate.search.util.logging.impl.LoggerHelper Maven / Gradle / Ivy

/*
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.search.util.logging.impl;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;

/**
 * @author Hardy Ferentschik
 */
public final class LoggerHelper {

	private static final Log log = LoggerFactory.make();

	private LoggerHelper() {
		//now allowed
	}

	public static PrintStream getLoggingPrintStream() {
		try {
			return new PrintStream( new CustomByteArrayOutputStream(), true, "UTF-8" );
		}
		catch (UnsupportedEncodingException e) {
			throw log.assertionNotLoadingUTF8Charset( e );
		}
	}

	static class CustomByteArrayOutputStream extends ByteArrayOutputStream {
		@Override
		public void flush() throws IOException {
			log.debug( this.toString( "UTF-8" ) );
			super.flush();
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy