001/** 002 * 003 * Copyright 2014 Florian Schmaus 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smack.debugger; 018 019import java.io.Reader; 020import java.io.Writer; 021import java.util.logging.Level; 022import java.util.logging.Logger; 023 024import org.jivesoftware.smack.XMPPConnection; 025 026/** 027 * Very simple debugger that prints to the console (stdout) the sent and received stanzas. Use 028 * this debugger with caution since printing to the console is an expensive operation that may 029 * even block the thread since only one thread may print at a time. 030 * <p> 031 * It is possible to not only print the raw sent and received stanzas but also the interpreted 032 * packets by Smack. By default interpreted packets won't be printed. To enable this feature 033 * just change the <tt>printInterpreted</tt> static variable to <tt>true</tt>. 034 * </p> 035 * 036 * @author Gaston Dombiak 037 */ 038public class JulDebugger extends AbstractDebugger { 039 040 private static final Logger LOGGER = Logger.getLogger(JulDebugger.class.getName()); 041 042 public JulDebugger(XMPPConnection connection, Writer writer, Reader reader) { 043 super(connection, writer, reader); 044 } 045 046 @Override 047 protected void log(String logMessage) { 048 LOGGER.fine(logMessage); 049 } 050 051 @Override 052 protected void log(String logMessage, Throwable throwable) { 053 LOGGER.log(Level.FINE, logMessage, throwable); 054 } 055}