Changeset 14070 in josm


Ignore:
Timestamp:
2018-08-01T19:21:43+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16547 - Display log messages with log levels warn and higher in the console (patch by floscher)

File:
1 edited

Legend:

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

    r14062 r14070  
    6262        private final Handler prioritizedHandler;
    6363        private OutputStream outputStreamMemo;
     64        /**
     65         * This variables is set to true as soon as the superconstructor has completed.
     66         * The superconstructor calls {@code setOutputStream(System.err)}, any subsequent call of
     67         * {@link #setOutputStream(OutputStream)} would then flush and close {@link System#err}. To avoid this,
     68         * we override {@link #setOutputStream(OutputStream)} to completely ignore all calls from the superconstructor.
     69         */
     70        private boolean superCompleted = false;
    6471
    6572        /**
     
    7683            final Handler prioritizedHandler
    7784        ) {
     85            super();
     86            superCompleted = true;
    7887            this.outputStreamSupplier = outputStreamSupplier;
    7988            this.prioritizedHandler = prioritizedHandler;
     
    98107        @Override
    99108        public synchronized void setOutputStream(final OutputStream outputStream) {
    100             // this wouldn't be necessary if StreamHandler made it possible to see what the current
    101             // output stream is set to
    102             this.outputStreamMemo = outputStream;
    103             super.setOutputStream(outputStream);
     109            // Ignore calls from superconstructor (see javadoc of the variable for details)
     110            if (superCompleted) {
     111                // this wouldn't be necessary if StreamHandler made it possible to see what the current
     112                // output stream is set to
     113                this.outputStreamMemo = outputStream;
     114                super.setOutputStream(outputStream);
     115            }
    104116        }
    105117
Note: See TracChangeset for help on using the changeset viewer.