<commit_before>/*
 * JBoss, Home of Professional Open Source
 *
 * Copyright 2009, Red Hat Middleware LLC, and individual contributors
 * by the @author tags. See the COPYRIGHT.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.netty.handler.logging;

import static org.jboss.netty.buffer.ChannelBuffers.*;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.ChannelDownstreamHandler;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelUpstreamHandler;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;

/**
 * A {@link ChannelHandler} that logs all events in <tt>DEBUG</tt> level.  This
 * handler is supposed to be used for debugging purpose only as the amount of
 * logged events will be large.
 *
 * @author The Netty Project (<EMAIL>)
 * @author <NAME> (<EMAIL>)
 * @version $Rev$, $Date$
 */
@ChannelPipelineCoverage("all")
public class LoggingHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler {

    private final InternalLogger logger;
    private final boolean hexDump;

    public LoggingHandler() {
        this(true);
    }

    public LoggingHandler(boolean hexDump) {
        logger = InternalLoggerFactory.getInstance(getClass());
        this.hexDump = hexDump;
    }

    public LoggingHandler(Class<?> clazz) {
        this(clazz, true);
    }

    public LoggingHandler(Class<?> clazz, boolean hexDump) {
        if (clazz == null) {
            throw new NullPointerException("clazz");
        }
        logger = InternalLoggerFactory.getInstance(clazz);
        this.hexDump = hexDump;
    }

    public LoggingHandler(String name) {
        this(name, true);
    }

    public LoggingHandler(String name, boolean hexDump) {
        if (name == null) {
            throw new NullPointerException("name");
        }
        logger = InternalLoggerFactory.getInstance(name);
        this.hexDump = hexDump;
    }

    public InternalLogger getLogger() {
        return logger;
    }

    public void log(ChannelEvent e) {
        if (isLogEnabled(e)) {
            String msg = e.toString();

            // Append hex dump if necessary.
            if (hexDump && e instanceof MessageEvent) {
                MessageEvent me = (MessageEvent) e;
                if (me.getMessage() instanceof ChannelBuffer) {
                    ChannelBuffer buf = (ChannelBuffer) me.getMessage();
                    msg = msg + " - (HEXDUMP: " + hexDump(buf) + ')';
                }
            }

            // Log the message (and exception if available.)
            if (e instanceof ExceptionEvent) {
                log(msg, ((ExceptionEvent) e).getCause());
            } else {
                log(msg);
            }
        }
    }

    public boolean isLogEnabled(@SuppressWarnings("unused") ChannelEvent e) {
        return getLogger().isDebugEnabled();
    }

    public void log(String msg) {
        getLogger().debug(msg);
    }

    public void log(String msg, Throwable cause) {
        getLogger().debug(msg, cause);
    }

    public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
            throws Exception {
        log(e);
        ctx.sendUpstream(e);
    }

    public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
            throws Exception {
        log(e);
        ctx.sendDownstream(e);
    }
}
<commit_msg>Method ordering<commit_after>/*
 * JBoss, Home of Professional Open Source
 *
 * Copyright 2009, Red Hat Middleware LLC, and individual contributors
 * by the @author tags. See the COPYRIGHT.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.netty.handler.logging;

import static org.jboss.netty.buffer.ChannelBuffers.*;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.ChannelDownstreamHandler;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelUpstreamHandler;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;

/**
 * A {@link ChannelHandler} that logs all events in <tt>DEBUG</tt> level.  This
 * handler is supposed to be used for debugging purpose only as the amount of
 * logged events will be large.
 *
 * @author The Netty Project (<EMAIL>)
 * @author <NAME> (<EMAIL>)
 * @version $Rev$, $Date$
 */
@ChannelPipelineCoverage("all")
public class LoggingHandler implements ChannelUpstreamHandler, ChannelDownstreamHandler {

    private final InternalLogger logger;
    private final boolean hexDump;

    public LoggingHandler() {
        this(true);
    }

    public LoggingHandler(boolean hexDump) {
        logger = InternalLoggerFactory.getInstance(getClass());
        this.hexDump = hexDump;
    }

    public LoggingHandler(Class<?> clazz) {
        this(clazz, true);
    }

    public LoggingHandler(Class<?> clazz, boolean hexDump) {
        if (clazz == null) {
            throw new NullPointerException("clazz");
        }
        logger = InternalLoggerFactory.getInstance(clazz);
        this.hexDump = hexDump;
    }

    public LoggingHandler(String name) {
        this(name, true);
    }

    public LoggingHandler(String name, boolean hexDump) {
        if (name == null) {
            throw new NullPointerException("name");
        }
        logger = InternalLoggerFactory.getInstance(name);
        this.hexDump = hexDump;
    }

    public InternalLogger getLogger() {
        return logger;
    }

    public boolean isLogEnabled(@SuppressWarnings("unused") ChannelEvent e) {
        return getLogger().isDebugEnabled();
    }

    public void log(ChannelEvent e) {
        if (isLogEnabled(e)) {
            String msg = e.toString();

            // Append hex dump if necessary.
            if (hexDump && e instanceof MessageEvent) {
                MessageEvent me = (MessageEvent) e;
                if (me.getMessage() instanceof ChannelBuffer) {
                    ChannelBuffer buf = (ChannelBuffer) me.getMessage();
                    msg = msg + " - (HEXDUMP: " + hexDump(buf) + ')';
                }
            }

            // Log the message (and exception if available.)
            if (e instanceof ExceptionEvent) {
                log(msg, ((ExceptionEvent) e).getCause());
            } else {
                log(msg);
            }
        }
    }

    public void log(String msg) {
        getLogger().debug(msg);
    }

    public void log(String msg, Throwable cause) {
        getLogger().debug(msg, cause);
    }

    public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
            throws Exception {
        log(e);
        ctx.sendUpstream(e);
    }

    public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
            throws Exception {
        log(e);
        ctx.sendDownstream(e);
    }
}

{'fraction_non_alphanumeric': 0.09356855739169272, 'fraction_numerical': 0.003796337650736936, 'mean_word_length': 2.782516891891892, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '532583', 'n_tokens_mistral': 2492, 'n_tokens_neox': 2399, 'n_words': 767}