Ignore:
Timestamp:
2013-09-23T16:47:50+02:00 (11 years ago)
Author:
Don-vip
Message:

Rework console output:

  • new log level "error"
  • Replace nearly all calls to system.out and system.err to Main.(error|warn|info|debug)
  • Remove some unnecessary debug output
  • Some messages are modified (removal of "Info", "Warning", "Error" from the message itself -> notable i18n impact but limited to console error messages not seen by the majority of users, so that's ok)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java

    r6087 r6248  
    77import java.net.InetSocketAddress;
    88import java.net.Proxy;
     9import java.net.Proxy.Type;
    910import java.net.ProxySelector;
    1011import java.net.SocketAddress;
    1112import java.net.URI;
    12 import java.net.Proxy.Type;
    1313import java.util.Collections;
    1414import java.util.List;
     
    7979            port = Integer.parseInt(value);
    8080        } catch (NumberFormatException e) {
    81             System.err.println(tr("Unexpected format for port number in in preference ''{0}''. Got ''{1}''.", property, value));
    82             System.err.println(tr("The proxy will not be used."));
     81            Main.error(tr("Unexpected format for port number in in preference ''{0}''. Got ''{1}''.", property, value));
     82            Main.error(tr("The proxy will not be used."));
    8383            return 0;
    8484        }
    8585        if (port <= 0 || port >  65535) {
    86             System.err.println(tr("Illegal port number in preference ''{0}''. Got {1}.", property, port));
    87             System.err.println(tr("The proxy will not be used."));
     86            Main.error(tr("Illegal port number in preference ''{0}''. Got {1}.", property, port));
     87            Main.error(tr("The proxy will not be used."));
    8888            return 0;
    8989        }
     
    102102            proxyPolicy= ProxyPolicy.fromName(value);
    103103            if (proxyPolicy == null) {
    104                 System.err.println(tr("Warning: unexpected value for preference ''{0}'' found. Got ''{1}''. Will use no proxy.", ProxyPreferencesPanel.PROXY_POLICY, value));
     104                Main.warn(tr("Unexpected value for preference ''{0}'' found. Got ''{1}''. Will use no proxy.", ProxyPreferencesPanel.PROXY_POLICY, value));
    105105                proxyPolicy = ProxyPolicy.NO_PROXY;
    106106            }
     
    113113            httpProxySocketAddress = null;
    114114            if (proxyPolicy.equals(ProxyPolicy.USE_HTTP_PROXY)) {
    115                 System.err.println(tr("Warning: Unexpected parameters for HTTP proxy. Got host ''{0}'' and port ''{1}''.", host, port));
    116                 System.err.println(tr("The proxy will not be used."));
     115                Main.warn(tr("Unexpected parameters for HTTP proxy. Got host ''{0}'' and port ''{1}''.", host, port));
     116                Main.warn(tr("The proxy will not be used."));
    117117            }
    118118        }
     
    125125            socksProxySocketAddress = null;
    126126            if (proxyPolicy.equals(ProxyPolicy.USE_SOCKS_PROXY)) {
    127                 System.err.println(tr("Warning: Unexpected parameters for SOCKS proxy. Got host ''{0}'' and port ''{1}''.", host, port));
    128                 System.err.println(tr("The proxy will not be used."));
     127                Main.warn(tr("Unexpected parameters for SOCKS proxy. Got host ''{0}'' and port ''{1}''.", host, port));
     128                Main.warn(tr("The proxy will not be used."));
    129129            }
    130130        }
     
    133133    @Override
    134134    public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
    135         // Just log something. The network stack will also throw an exception which will be caught
    136         // somewhere else
     135        // Just log something. The network stack will also throw an exception which will be caught somewhere else
    137136        //
    138         System.out.println(tr("Error: Connection to proxy ''{0}'' for URI ''{1}'' failed. Exception was: {2}", sa.toString(), uri.toString(), ioe.toString()));
     137        Main.error(tr("Connection to proxy ''{0}'' for URI ''{1}'' failed. Exception was: {2}", sa.toString(), uri.toString(), ioe.toString()));
    139138    }
    140139
     
    145144        case USE_SYSTEM_SETTINGS:
    146145            if (!JVM_WILL_USE_SYSTEM_PROXIES) {
    147                 System.err.println(tr("Warning: the JVM is not configured to lookup proxies from the system settings. The property ''java.net.useSystemProxies'' was missing at startup time.  Will not use a proxy."));
     146                Main.warn(tr("The JVM is not configured to lookup proxies from the system settings. The property ''java.net.useSystemProxies'' was missing at startup time.  Will not use a proxy."));
    148147                return Collections.singletonList(Proxy.NO_PROXY);
    149148            }
Note: See TracChangeset for help on using the changeset viewer.