Changeset 8b05b16


Ignore:
Timestamp:
Aug 28, 2011 6:47:13 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
5b114182
Parents:
d4bf3403
Message:
  • Log: Fix level stuck at DEBUG when called from constructor
Location:
core/java/src/net/i2p/util
Files:
2 edited

Legend:

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

    rd4bf3403 r8b05b16  
    2424 */
    2525public class Log {
    26     private Class _class;
    27     private String _className;
    28     private String _name;
     26    private final Class _class;
     27    private final String _className;
     28    private final String _name;
    2929    private int _minPriority;
    30     private LogScope _scope;
    31     private LogManager _manager;
     30    private final LogScope _scope;
     31    private final LogManager _manager;
    3232
    3333    public final static int DEBUG = 10;
     
    7070    }
    7171
     72    /**
     73     *  Warning - not recommended.
     74     *  Use I2PAppContext.getGlobalContext().logManager().getLog(cls)
     75     */
    7276    public Log(Class cls) {
    7377        this(I2PAppContext.getGlobalContext().logManager(), cls, null);
     
    7579    }
    7680
     81    /**
     82     *  Warning - not recommended.
     83     *  Use I2PAppContext.getGlobalContext().logManager().getLog(name)
     84     */
    7785    public Log(String name) {
    7886        this(I2PAppContext.getGlobalContext().logManager(), null, name);
     
    191199        return name + "" + cls.getName();
    192200    }
     201
    193202    private static final class LogScope {
    194         private String _scopeName;
    195         private Class _scopeClass;
    196         private String _scopeCache;
     203        private final String _scopeName;
     204        private final Class _scopeClass;
     205        private final String _scopeCache;
     206
    197207        public LogScope(String name, Class cls) {
    198208            _scopeName = name;
     
    200210            _scopeCache = getScope(name, cls);
    201211        }
     212
    202213        @Override
    203214        public int hashCode() {
    204215            return _scopeCache.hashCode();
    205216        }
     217
    206218        @Override
    207219        public boolean equals(Object obj) {
  • core/java/src/net/i2p/util/LogManager.java

    rd4bf3403 r8b05b16  
    180180    }
    181181
     182    /**
     183     *  If the log already exists, its priority is set here but cannot
     184     *  be changed later, as it becomes an "orphan" not tracked by the manager.
     185     */
    182186    void addLog(Log log) {
    183187        Log old = _logs.putIfAbsent(log.getScope(), log);
    184         if (old == null)
    185             updateLimit(log);
     188        updateLimit(log);
     189        if (old != null) {
     190            if (_log.shouldLog(Log.INFO))
     191                _log.info("Duplicate log for " + log.getName());
     192        }
    186193    }
    187194   
Note: See TracChangeset for help on using the changeset viewer.