<commit_before>//
// $Id$
//
// Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets
// http://github.com/samskivert/nexus/blob/master/LICENSE

package com.samskivert.nexus.client;

import com.samskivert.nexus.io.GWTIO;
import com.samskivert.nexus.net.Connection;
import com.samskivert.nexus.net.GWTConnection;
import com.samskivert.nexus.util.Callback;

/**
 * Provides a Nexus client using WebSockets and GWT-based I/O.
 */
public class GWTClient extends NexusClient
{
    /**
     * Creates a Nexus client which will use WebSockets to connect to hosts.
     * @param port the port on which to make WebSocket connections.
     * @param szer the serializer that knows about all types that will cross the wire.
     */
    public static NexusClient create (int port, GWTIO.Serializer szer)
    {
        return new GWTClient(port, szer);
    }

    protected GWTClient (int port, GWTIO.Serializer szer)
    {
        _port = port;
        _szer = szer;
    }

    protected void connect (String host, Callback<Connection> callback)
    {
        new GWTConnection(host, _port, _szer, callback);
    }

    protected int _port;
    protected GWTIO.Serializer _szer;
}<commit_msg>Wire our logging into GWT when running a GWT client.<commit_after>//
// $Id$
//
// Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets
// http://github.com/samskivert/nexus/blob/master/LICENSE

package com.samskivert.nexus.client;

import com.google.gwt.core.client.GWT;

import com.samskivert.nexus.io.GWTIO;
import com.samskivert.nexus.net.Connection;
import com.samskivert.nexus.net.GWTConnection;
import com.samskivert.nexus.util.Callback;
import com.samskivert.nexus.util.Log;

/**
 * Provides a Nexus client using WebSockets and GWT-based I/O.
 */
public class GWTClient extends NexusClient
{
    /**
     * Creates a Nexus client which will use WebSockets to connect to hosts.
     * @param port the port on which to make WebSocket connections.
     * @param szer the serializer that knows about all types that will cross the wire.
     */
    public static NexusClient create (int port, GWTIO.Serializer szer)
    {
        Log.log = GWT_LOGGER; // configure the logger to use GWT
        return new GWTClient(port, szer);
    }

    protected GWTClient (int port, GWTIO.Serializer szer)
    {
        _port = port;
        _szer = szer;
    }

    protected void connect (String host, Callback<Connection> callback)
    {
        new GWTConnection(host, _port, _szer, callback);
    }

    protected int _port;
    protected GWTIO.Serializer _szer;

    protected static final Log.Logger GWT_LOGGER = new Log.Logger() {
        public void info (String message, Object... args) {
            if (!_warnOnly) {
                format(null, message, args);
            }
        }
        public void warning (String message, Object... args) {
            format(null, message, args);
        }
        public void log (Object level, String message, Throwable cause) {
            GWT.log(message, cause);
        }
        public void setWarnOnly () {
            _warnOnly = true;
        }
        protected boolean _warnOnly;
    };
}
{'fraction_non_alphanumeric': 0.0926860025220681, 'fraction_numerical': 0.0, 'mean_word_length': 2.642939150401837, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5999503', 'n_tokens_mistral': 1006, 'n_tokens_neox': 974, 'n_words': 301}