Changeset 6852 in josm for trunk/src


Ignore:
Timestamp:
2014-02-14T16:08:08+01:00 (6 years ago)
Author:
Don-vip
Message:

see #9710 - more debug messages

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

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

    r6806 r6852  
    282282
    283283    /**
     284     * Determines if debug log level is enabled.
     285     * Useful to avoid costly construction of debug messages when not enabled.
     286     * @return {@code true} if log level is at least debug, {@code false} otherwise
     287     * @since 6852
     288     */
     289    public static boolean isDebugEnabled() {
     290        return logLevel >= 4;
     291    }
     292
     293    /**
     294     * Determines if trace log level is enabled.
     295     * Useful to avoid costly construction of trace messages when not enabled.
     296     * @return {@code true} if log level is at least trace, {@code false} otherwise
     297     * @since 6852
     298     */
     299    public static boolean isTraceEnabled() {
     300        return logLevel >= 5;
     301    }
     302
     303    /**
    284304     * Prints a formatted error message if logging is on. Calls {@link MessageFormat#format}
    285305     * function to format text.
     
    595615            final long startTime = System.currentTimeMillis();
    596616            initialize();
    597             final long elapsedTime = System.currentTimeMillis() - startTime;
    598             Main.debug(tr("{0} completed in {1}", name, Utils.getDurationString(elapsedTime)));
     617            if (isDebugEnabled()) {
     618                final long elapsedTime = System.currentTimeMillis() - startTime;
     619                Main.debug(tr("{0} completed in {1}", name, Utils.getDurationString(elapsedTime)));
     620            }
    599621            return null;
    600622        }
     
    660682        return getEditLayer().data;
    661683    }
    662    
     684
    663685    /**
    664686     * Replies the current selected primitives, from a end-user point of view.
     
    666688     * Indeed, if the user is currently in drawing mode, only the way currently being drawn is returned,
    667689     * see {@link DrawAction#getInProgressSelection()}.
    668      * 
     690     *
    669691     * @return The current selected primitives, from a end-user point of view. Can be {@code null}.
    670692     * @since 6546
     
    14211443     * Adds a new network error that occur to give a hint about broken Internet connection.
    14221444     * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
    1423      * 
     1445     *
    14241446     * @param url The accessed URL that caused the error
    14251447     * @param t The network error
     
    14411463     * Adds a new network error that occur to give a hint about broken Internet connection.
    14421464     * Do not use this method for errors known for sure thrown because of a bad proxy configuration.
    1443      * 
     1465     *
    14441466     * @param url The accessed URL that caused the error
    14451467     * @param t The network error
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r6830 r6852  
    308308            initializeTests(getTests());
    309309            testsInitialized = true;
    310             final long elapsedTime = System.currentTimeMillis() - startTime;
    311             Main.debug("Initializing validator tests completed in " + Utils.getDurationString(elapsedTime));
     310            if (Main.isDebugEnabled()) {
     311                final long elapsedTime = System.currentTimeMillis() - startTime;
     312                Main.debug("Initializing validator tests completed in " + Utils.getDurationString(elapsedTime));
     313            }
    312314        }
    313315    }
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r6798 r6852  
    259259                            wait(1000);
    260260                        } catch (InterruptedException e) {
    261                             // Occurs frequently during JOSM shutdown, log set to debug only
    262                             Main.debug("InterruptedException in "+MapStatus.class.getSimpleName());
     261                            // Occurs frequently during JOSM shutdown, log set to trace only
     262                            Main.trace("InterruptedException in "+MapStatus.class.getSimpleName());
    263263                        }
    264264                        ms.modifiers = mouseState.modifiers;
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r6840 r6852  
    687687                    errorHeader = activeConnection.getHeaderField("Error");
    688688                    Main.error("Error header: " + errorHeader);
    689                 } else if (retCode != 200 && responseBody.length()>0) {
     689                } else if (retCode != HttpURLConnection.HTTP_OK && responseBody.length()>0) {
    690690                    Main.error("Error body: " + responseBody);
    691691                }
    692692                activeConnection.disconnect();
     693
     694                if (Main.isDebugEnabled()) {
     695                    Main.debug("RESPONSE: "+ activeConnection.getHeaderFields());
     696                }
    693697
    694698                errorHeader = errorHeader == null? null : errorHeader.trim();
     
    723727                }
    724728                throw new OsmTransferException(e);
    725             } catch(IOException e){
     729            } catch(IOException e) {
    726730                throw new OsmTransferException(e);
    727             } catch(OsmTransferCanceledException e){
     731            } catch(OsmTransferCanceledException e) {
    728732                throw e;
    729733            } catch(OsmTransferException e) {
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r6803 r6852  
    158158            }
    159159            try {
    160                 Main.debug(activeConnection.getHeaderFields().toString());
     160                if (Main.isDebugEnabled()) {
     161                    Main.debug("RESPONSE: "+activeConnection.getHeaderFields());
     162                }
    161163                if (activeConnection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED)
    162164                    throw new OsmApiException(HttpURLConnection.HTTP_UNAUTHORIZED,null,null);
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6830 r6852  
    749749            connection.setRequestProperty("Connection", "close");
    750750        }
     751        if (Main.isDebugEnabled()) {
     752            try {
     753                Main.debug("REQUEST: "+ connection.getRequestProperties());
     754            } catch (IllegalStateException e) {
     755                Main.warn(e);
     756            }
     757        }
    751758        return connection;
    752759    }
Note: See TracChangeset for help on using the changeset viewer.