Changeset 50ec279


Ignore:
Timestamp:
Sep 10, 2012 10:38:18 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
d7b48a22
Parents:
e8a8f3c
Message:

use partial match for dups; add config for dups

Location:
core/java/src/net/i2p/util
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/util/LogManager.java

    re8a8f3c r50ec279  
    5959    /** @since 0.9.2 */
    6060    private static final String PROP_DROP = "logger.dropOnOverflow";
     61    /** @since 0.9.3 */
     62    private static final String PROP_DUP = "logger.dropDuplicates";
    6163    public final static String PROP_RECORD_PREFIX = "logger.record.";
    6264
     
    121123    private int _logBufferSize = MAX_BUFFER;
    122124    private boolean _dropOnOverflow;
     125    private boolean _dropDuplicates;
    123126    private final AtomicLong _droppedRecords = new AtomicLong();
    124127   
     
    281284
    282285    /**
     286     *  @since 0.9.3
     287     */
     288    boolean shouldDropDuplicates() {
     289        return _dropDuplicates;
     290    }
     291
     292    /**
    283293     * Do not log here, deadlock of LogWriter via rereadConfig().
    284294     */
     
    369379        } catch (NumberFormatException nfe) {}
    370380
    371         _dropOnOverflow = Boolean.valueOf(config.getProperty(PROP_DROP)).booleanValue();
     381        _dropOnOverflow = Boolean.parseBoolean(config.getProperty(PROP_DROP));
     382        String str = config.getProperty(PROP_DUP);
     383        _dropDuplicates = str == null || Boolean.parseBoolean(str);
    372384
    373385        //if (_log.shouldLog(Log.DEBUG))
  • core/java/src/net/i2p/util/LogRecord.java

    re8a8f3c r50ec279  
    11package net.i2p.util;
    2 
    3 import net.i2p.data.DataHelper;
    42
    53/*
     
    6361    }
    6462
     63    private static final int MATCH_LEN = 40;
     64
    6565    /**
    66      *  Matches source class, message string, and throwable class only.
     66     *  Matches source class, first part of message string, and throwable class only.
     67     *  Used only by LogWriter to eliminate dups.
    6768     *  @since 0.9.3
    6869     */
     
    7374        LogRecord r = (LogRecord) o;
    7475        return _source == r._source &&
    75                DataHelper.eq(_message, r._message) &&
     76               ((_message == null && r._message == null) ||
     77                (_message != null && r._message != null &&
     78                 ((_message.length() <= MATCH_LEN) ? _message.equals(r._message)
     79                                                   : _message.regionMatches(0, r._message, 0, MATCH_LEN)))) &&
    7680               ((_throwable == null && r._throwable == null) ||
    7781                (_throwable != null && r._throwable != null && _throwable.getClass() == r._throwable.getClass()));
  • core/java/src/net/i2p/util/LogWriter.java

    re8a8f3c r50ec279  
    7878                int dupCount = 0;
    7979                while ((rec = records.poll()) != null) {
    80                     if (rec.equals(last)) {
     80                    if (_manager.shouldDropDuplicates() && rec.equals(last)) {
    8181                        dupCount++;
    8282                    } else {
Note: See TracChangeset for help on using the changeset viewer.