Re: Enums and Custom Levels - a few minor changes

2014-01-26 Thread Ralph Goers
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



Re: Enums and Custom Levels - a few minor changes

2014-01-26 Thread Remko Popma
The switch in o.a.l.Category.getEffectiveLevel() in log4j-1.2-api is
missing the FATAL level (and perhaps OFF also).
Is this intentional?

On Monday, January 27, 2014, Ralph Goers ralph.go...@dslextreme.com wrote:

 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.netjavascript:;
 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.orgjavascript:;
 For additional commands, e-mail: 
 log4j-dev-h...@logging.apache.orgjavascript:;




Re: Enums and Custom Levels - a few minor changes

2014-01-26 Thread Ralph Goers
You mentioned that before and I didn’t check since it has been that way from 
the beginning.  Yes it looks like a bug to me.  

Ralph

On Jan 26, 2014, at 7:06 PM, Remko Popma remko.po...@gmail.com wrote:

 The switch in o.a.l.Category.getEffectiveLevel() in log4j-1.2-api is missing 
 the FATAL level (and perhaps OFF also). 
 Is this intentional?
 
 On Monday, January 27, 2014, Ralph Goers ralph.go...@dslextreme.com wrote:
 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
 



Re: Enums and Custom Levels - a few minor changes

2014-01-26 Thread Remko Popma
Understood. I can't commit from work but I can fix this when I get home
tonight.

On Monday, January 27, 2014, Ralph Goers ralph.go...@dslextreme.com wrote:

 You mentioned that before and I didn’t check since it has been that way
 from the beginning.  Yes it looks like a bug to me.

 Ralph

 On Jan 26, 2014, at 7:06 PM, Remko Popma 
 remko.po...@gmail.comjavascript:_e({}, 'cvml', 'remko.po...@gmail.com');
 wrote:

 The switch in o.a.l.Category.getEffectiveLevel() in log4j-1.2-api is
 missing the FATAL level (and perhaps OFF also).
 Is this intentional?

 On Monday, January 27, 2014, Ralph Goers 
 ralph.go...@dslextreme.comjavascript:_e({}, 'cvml', 
 'ralph.go...@dslextreme.com');
 wrote:

 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