I modified Level to be final and have a private constructor. I added a static method named getOrCreateLevel. Custom extensions should use that method to create the static reference. This allows the new Level to be declared in multiple places without a problem as they will all get the same Level instance.
I also removed the ordinal and the synchronization associated with it. Ralph On Jan 26, 2014, at 2:40 PM, Nick Williams <nicho...@nicholaswilliams.net> wrote: > I would be OK with getting rid of the ordinal. It makes it less enum-like, > but I agree that the ordinal really has little purpose now. The intLevel is > more important. > > Here may be the best approach I can think of for calculating the > StandardLevel-equivalent on instantiation: > > public static Level OFF = new Level("OFF", 0, StandardLevel.OFF) {}; > ... > public static Level ALL = new Level("ALL", Integer.MAX_VALUE, > StandardLevel.ALL); > > ... > > private Level(String name, int intLevel, StandardLevel standardLevel) { // > this is the only c-tor standard levels use > // same logic as current constructor > this.standardLevel = standardLevel; > } > > protected Level(String name, int intLevel) { // this is the only c-tor > custom levels use > this(name, intLevel, Level.calculateStandardLevel(intLevel)); > } > > public enum StandardLevel { > OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL > } > > Thoughts? > > N --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org