001/**
002 *
003 * Copyright © 2014-2021 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.smackx.debugger.android;
018
019import org.jivesoftware.smack.XMPPConnection;
020import org.jivesoftware.smack.debugger.AbstractDebugger;
021
022import android.util.Log;
023
024/**
025 * Very simple debugger that prints to the android log the sent and received stanzas.
026 * <p>
027 * Only use this debugger if really required, Android has a good java.util.logging
028 * implementation, therefore {@link org.jivesoftware.smack.debugger.JulDebugger} is preferred.
029 * </p>
030 * It is possible to not only print the raw sent and received stanzas but also the interpreted
031 * packets by Smack. By default interpreted packets won't be printed. To enable this feature
032 * just change the <code>printInterpreted</code> static variable to <code>true</code>.
033 *
034 */
035public class AndroidDebugger extends AbstractDebugger {
036
037    /**
038     * Constructs a new Smack debugger for Android.
039     *
040     * @param connection the connection to debug.
041     */
042    public AndroidDebugger(XMPPConnection connection) {
043        super(connection);
044    }
045
046    @Override
047    protected void log(String logMessage) {
048                Log.d("SMACK", logMessage);
049    }
050
051    @Override
052    protected void log(String logMessage, Throwable throwable) {
053                Log.d("SMACK", logMessage, throwable);
054    }
055}