// Path: toybox/src/main/java/com/threerings/toybox/Log.java
// public static Logger log = Logger.getLogger("com.threerings.toybox");


import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import com.threerings.media.FrameManager;
import com.threerings.presents.client.Client;
import static com.threerings.toybox.Log.log;
    public static void start (
        ToyBoxApp app, String server, int port, String username, String password)
    {
        try {
            // initialize the app (use defaults that work when running in
            // development mode)
            String gid = System.getProperty("game_id", "-1");
            String rurl = System.getProperty("resource_url", "file://dist");
            app.init(username, gid, rurl);
        } catch (IOException ioe) {
            log.warning("Error initializing application.", ioe);
        }

        // and run it
        app.run(server, port, username, password);
    }

    public static void main (String[] args)
    {
        // we do this all in a strange order to avoid logging anything until we set up our log
        // formatter but we can't do that until after we've redirected system out and err
        String dlog = null;
        if (System.getProperty("no_log_redir") == null) {
            dlog = ToyBoxClient.localDataDir("toybox.log");
            try {
                PrintStream logOut = new PrintStream(new FileOutputStream(dlog), true);
                System.setOut(logOut);
                System.setErr(logOut);

            } catch (IOException ioe) {
// Path: toybox/src/main/java/com/threerings/toybox/Log.java
// public static Logger log = Logger.getLogger("com.threerings.toybox");


// Path: toybox/src/main/java/com/threerings/toybox/client/ToyBoxApp.java
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import com.threerings.media.FrameManager;
import com.threerings.presents.client.Client;
import static com.threerings.toybox.Log.log;

    public static void start (
        ToyBoxApp app, String server, int port, String username, String password)
    {
        try {
            // initialize the app (use defaults that work when running in
            // development mode)
            String gid = System.getProperty("game_id", "-1");
            String rurl = System.getProperty("resource_url", "file://dist");
            app.init(username, gid, rurl);
        } catch (IOException ioe) {
            log.warning("Error initializing application.", ioe);
        }

        // and run it
        app.run(server, port, username, password);
    }

    public static void main (String[] args)
    {
        // we do this all in a strange order to avoid logging anything until we set up our log
        // formatter but we can't do that until after we've redirected system out and err
        String dlog = null;
        if (System.getProperty("no_log_redir") == null) {
            dlog = ToyBoxClient.localDataDir("toybox.log");
            try {
                PrintStream logOut = new PrintStream(new FileOutputStream(dlog), true);
                System.setOut(logOut);
                System.setErr(logOut);

            } catch (IOException ioe) {
                log.warning("Failed to open debug log [path=" + dlog + ", error=" + ioe + "].");