Re: Enums and Custom Levels - completed.

2014-01-28 Thread Remko Popma
I was going to make the change but ran out of time... No rush though, I just didn't want to forget about it and have it cause issues later in the generated code. (I'll bring this - maintenance - up in the other thread. ) On Wednesday, January 29, 2014, Ralph Goers > wrote: > I can do it but it wo

Re: Enums and Custom Levels - completed.

2014-01-28 Thread Ralph Goers
I can do it but it won't be for another 8 hrs or so. If you need it sooner go ahead. Sent from my iPad > On Jan 28, 2014, at 9:00 AM, Remko Popma wrote: > > Who will make this change (getOrCreateLevel -> forName) ? > I'm asking because I'm calling this method in the generated wrapper source >

Re: Enums and Custom Levels - completed.

2014-01-28 Thread Remko Popma
Who will make this change (getOrCreateLevel -> forName) ? I'm asking because I'm calling this method in the generated wrapper source code... On Mon, Jan 27, 2014 at 12:55 PM, Nick Williams < nicho...@nicholaswilliams.net> wrote: > Okay. I'm good with "forName," then. > > N > > On Jan 26, 2014, a

Re: Enums and Custom Levels - completed.

2014-01-27 Thread Nick Williams
> From: Ralph Goers > Date:01/27/2014 11:19 (GMT-05:00) > To: Log4J Developers List > Subject: Re: Enums and Custom Levels - completed. > > If the user creates a custom Logger Wrapper then they can just code against > that and not use an interface, correct? > > Ral

Re: Enums and Custom Levels - completed.

2014-01-27 Thread Gary Gregory
Yes that's the idea.  Gary Original message From: Ralph Goers Date:01/27/2014 11:19 (GMT-05:00) To: Log4J Developers List Subject: Re: Enums and Custom Levels - completed. If the user creates a custom Logger Wrapper then they can just code against that and not u

Re: Enums and Custom Levels - completed.

2014-01-27 Thread Ralph Goers
If the user creates a custom Logger Wrapper then they can just code against that and not use an interface, correct? Ralph On Jan 27, 2014, at 6:40 AM, Nick Williams wrote: > Wrapping a logger /implementation/ is fine. But the user needs an /interface/ > to program against. That interface sho

Re: Enums and Custom Levels - completed.

2014-01-27 Thread Nick Williams
Wrapping a logger /implementation/ is fine. But the user needs an /interface/ to program against. That interface should extend Logger rather than re-define all of Logger's methods. Nick On Jan 27, 2014, at 8:24 AM, Gary Gregory wrote: > Please note that in the case of domain specific logging (

Re: Enums and Custom Levels - completed.

2014-01-27 Thread Gary Gregory
Please note that in the case of domain specific logging (DSL!), I do not want to extend, I want to wrap a logger. See my DEFCON example. Gary On Sun, Jan 26, 2014 at 6:51 PM, Nick Williams < nicho...@nicholaswilliams.net> wrote: > Generating a logger /interface/ is going to be hard. Sure, writi

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
Okay. I'm good with "forName," then. N On Jan 26, 2014, at 9:51 PM, Ralph Goers wrote: > I disagree - you are getting the Level that matches the name, so forName does > describe what is happening. > > See the Javadoc on the second question. The intValue is ignored unless the > Level is creat

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I disagree - you are getting the Level that matches the name, so forName does describe what is happening. See the Javadoc on the second question. The intValue is ignored unless the Level is created. Yes, that could lead to some problems if there are conflicts, but I think returning the regist

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Matt Sicker
Perhaps if we called the priority or ordinal "power", then we'd have a great time with the naming scheme? On 26 January 2014 21:46, Nick Williams wrote: > Level.forName wouldn't work--it's not just "for name," it's for the name > /and/ the level. But it must be unique by the name. > > For that m

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Matt Sicker
I second my suggestion! On 26 January 2014 21:44, Ralph Goers wrote: > My first gut reaction was confusion over Class.forName(). But then in > thinking about it that name does behave a lot like what Class.forName() > does, except with a Level. So I think I do like it better than the current >

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
Level.forName wouldn't work--it's not just "for name," it's for the name /and/ the level. But it must be unique by the name. For that matter, what are we to do in the following situation? Level.getOrCreate("DIAG", 150); ... Level.getOrCreate("DIAG", 250); They're not going to get wh

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
My first gut reaction was confusion over Class.forName(). But then in thinking about it that name does behave a lot like what Class.forName() does, except with a Level. So I think I do like it better than the current name. Any other thoughts or opinions? Ralph On Jan 26, 2014, at 7:28 PM,

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Matt Sicker
How about Level.forName()? On 26 January 2014 21:06, Ralph Goers wrote: > No objections on spawning a separate thread for discussion 2. > > I also am not in love with the method name but it does describe what it > does. If anyone has any ideas on a better name please suggest it (we are > talki

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 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

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 wrote: > The switch in o.a.l.Category.getEffectiveLevel() in log4j-1.2-api is missing > the FATAL level (and perhaps OFF

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
No objections on spawning a separate thread for discussion 2. I also am not in love with the method name but it does describe what it does. If anyone has any ideas on a better name please suggest it (we are talking about the getOrCreateLevel method name). Ralph On Jan 26, 2014, at 6:59 PM, N

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 wrote: > I modified Level to be final and have a private constructor. I added a > static method named getOrCreateLev

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Paul Benedict
If you break off into another thread, I'll be watching; I'll throw in my 2 cents on how to make a custom Logger interface once that occurs. On Sun, Jan 26, 2014 at 9:01 PM, Ralph Goers wrote: > Yes, logger.log(MyCustomLEvels.LEVEL1, “message”); works right now. See > the ExtendedLevels class in

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
Yes, logger.log(MyCustomLEvels.LEVEL1, “message”); works right now. See the ExtendedLevels class in log4j-core test as an example on how to declare the level. I think several of us think that finding a way to make it easy to create extended logger methods would be very nice, but I don’t believ

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
There are two separate discussions going on here, so it's easy to get lost. We should probably split discussions again. Discussion 1: The finer details of custom levels. I'm fine with using a static factory method and making the constructor private, but I'm not a big fan of the name. Just sound

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Paul Benedict
I got lost in the discussion. Can someone please clarify... Is the custom logging interface a nice-to-have or a requirement of the system? I was hoping simply someone could write this (pseudocode below): logger.log(MyCustomLevels.LEVEL1, "message"); ...so no different interface should be required

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Matt Sicker
Now Level can't be used in an annotation. Since it supports string names for levels, should I just use Level.toLevel? On 26 January 2014 19:55, Ralph Goers wrote: > I think I must be misunderstanding the part about “If those levels were > added…”. I don’t understand how a level can be added to

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 Lev

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I think I must be misunderstanding the part about “If those levels were added…”. I don’t understand how a level can be added to a class from the config such that it is usable by a programmer at compile time. Ralph On Jan 26, 2014, at 5:24 PM, Scott Deboy wrote: > Couldn't we no-op instead of

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
Why would we want that? It is inconsistent with how we currently use Levels and I think it could lead to confusion. What I think should happen is that this Logger wrapper is also where the custom level should be declared. Ralph On Jan 26, 2014, at 5:32 PM, Nick Williams wrote: > Sorry, I wa

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
Sorry, I was leaving the method names off because the user can name the methods whatever they want to. They aren't important to the signature as far as Log4j is concerned. You /could/ get the level name from the method name, yes. Using an annotation would allow the user to have a constant, perh

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
We can’t no-op because the user is doing public static Level NOTE = new Level(“NOTE”, 123){}; Of course, this will generate a new object, not return a preexisting one. The only way around this would be to use a Level factory pattern such as public static Level NOTE = Level.getOrCreateLevel(“NO

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I think I am missing something. First, void(Marker, Message) isn’t a valid method signature so I am not sure what you are really intending. It looks like you specifically did not add the level to the method name and are planning on getting it from the annotation? If so, I don’t see how that w

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Scott Deboy
Couldn't we no-op instead of throw if the same identical level were registered? If those levels were then added to the same custom level class from the config, could we use that single class in the logger calls? On Jan 26, 2014 5:15 PM, "Ralph Goers" wrote: > I am certain I could create a Level

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I am certain I could create a LevelPlugin that would allow you to define one or more Levels in the configuration, but to use that Level the user would have to code: logger.log(Level.toLevel(“DIAG”), “hello world”); In order to directly reference the level it has to be declared as a static from

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Remko Popma
> Gary > > > Original message > From: Remko Popma > Date:01/26/2014 18:17 (GMT-05:00) > To: Log4J Developers List > Subject: Re: Enums and Custom Levels - completed. > > Scott, > The way I interpreted Gary's idea was that based on user-specified custom

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Gary Gregory
Please read my message again. I talk about wrapping not extending.  Gary Original message From: Remko Popma Date:01/26/2014 18:17 (GMT-05:00) To: Log4J Developers List Subject: Re: Enums and Custom Levels - completed. Scott, The way I interpreted Gary's idea was

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Matt Sicker
If the explicit values of the enum aren't used, then the logger methods that take a level would still work just fine. That's with the funky & Level> generic, too, right? On 26 January 2014 18:14, Ralph Goers wrote: > Oh, actually I used an Interface for Level and an enum for the standard > lev

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
Oh, actually I used an Interface for Level and an enum for the standard levels, so I didn’t try what you are suggesting. I don’t see how what you are proposing would work since all the Logger methods take a Level. If Level is an enum then only the values defined in it can be used, regardless o

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
My first implementation used a real enum that implemented a Level interface. I have to agree with Nick that what is currently committed is simpler. Ralph On Jan 26, 2014, at 4:00 PM, Matt Sicker wrote: > Don't annotation processing plugins work well in IDEs? Either way, there's a > maven plu

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I think this is very similar to my most recent commit. Since you are OK with removing the ordinal I am going to do that along with fix the problem Remko mentioned. Ralph On Jan 26, 2014, at 2:40 PM, Nick Williams wrote: > I would be OK with getting rid of the ordinal. It makes it less enum-

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Scott Deboy
I have one goal: to remove my request for new built in levels by allowing the levels to be defined strictly via configuration. I agree there may be some hurdles but that's my goal. I'd like to avoid the requirement that users provide their own level implementation or use a different API. Scott O

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Matt Sicker
Don't annotation processing plugins work well in IDEs? Either way, there's a maven plugin already available for doing that, and javac has some sort of support for it already. Also, I'm still advocating for using a real enum for Level while providing a Level interface for all the relevant methods.

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
Generating a logger /interface/ is going to be hard. Sure, writing the code automatically will be a piece of cake. But then what do we do with that code? The user needs to program against it. So we have to have a command-line utility or Maven/Ant plug-in to generate the source pre-compile. Howev

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Scott Deboy
Yes that's what I was thinking. Scott On Jan 26, 2014 3:18 PM, "Remko Popma" wrote: > Scott, > The way I interpreted Gary's idea was that based on user-specified custom > levels, we would generate an extension of the Logger interface that has a > method for each of the custom levels (well, actua

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
I agree. The circumstance that could cause a problem here would be rare, but not impossible. We should use Remko's code here. Nick On Jan 26, 2014, at 5:20 PM, Remko Popma wrote: > By the way, there may be a small concurrency bug in the Level.values() static > method. This may be better: > >

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Remko Popma
By the way, there may be a small concurrency bug in the Level.values() static method. This may be better: public static Level[] values() { Collection values = Level.levels.values(); return values.toArray(new Level[values.size()]); // use value collection size, not map size

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Remko Popma
Scott, The way I interpreted Gary's idea was that based on user-specified custom levels, we would generate an extension of the Logger interface that has a method for each of the custom levels (well, actually 14 methods for each level :-) ). I haven't really thought about how users would specify the

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Matt Sicker
+1 to everything Nick said. On 26 January 2014 16:40, Nick Williams 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

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
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 L

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I made most of the changes. I moved StandardLevel to a separate file in the spi sub-package. The actual level values are defined there and then referenced in Level. This way each Level can be associated with a StandardLevel in its constructor. Ralph On Jan 26, 2014, at 1:40 PM, Ralph Goers w

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I do have one other comment. You mention that the ordinal value isn’t guaranteed because the levels might be instantiated in a different order each time. An alternative wold be to just get rid of the ordinal. It isn’t used anywhere by anything and when custom values are added they will be adde

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I agree with most of this and will make the suggested changes. At least up to the point of getting rid of the StandardLevel enum. That is used in too many places to map to some other framework. I agree that doing the calculation every time is not the right way to go and will see what I can do,

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
Some (ok, a lot of) feedback: - `private static ConcurrentMap levels` should be final. - `private static Object constructorLock` should be final. In fact, code inspection flags this as a warning since code synchronizes on it. - The standard Level constants should be instantiated in a static ini

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Scott Deboy
Is there a way to generate code/update the Levels enumeration so a new Level class isn't required? Would be great to be able to use logger.detail("Detail message"); Is that what you're thinking of, Remko? On 1/26/14, Ralph Goers wrote: > I haven’t done anything to directly do that. However, cus

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I haven’t done anything to directly do that. However, custom levels need to be mapped to the standard levels in several places. It would be simple to add support for that wherever you want it. Level.StdLevel.getStdLevel() is the method used to do that. Ralph On Jan 26, 2014, at 7:45 AM, Scott

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I’ve committed the changes. Take a look at ExtendedLevels.java, ExtendedLevelTest.java and log4j-customLevel.xml in the log4j-core test directories to see how it works. Ralph On Jan 26, 2014, at 1:19 AM, Remko Popma wrote: > I'm very curious! Can't wait to see it. Go for it! > > On Sunday,

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
Never mind I see you just committed. :-) I'll review and provide feedback if necessary. N On Jan 26, 2014, at 1:36 PM, Nick Williams wrote: > Can you post a diff or the related files somewhere? Obviously it can be > tweaked after commit if necessary, but I'd like to see if there's anything >

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Nick Williams
Can you post a diff or the related files somewhere? Obviously it can be tweaked after commit if necessary, but I'd like to see if there's anything major that sticks out to me before you commit. Thanks, Nick On Jan 26, 2014, at 2:57 AM, Ralph Goers wrote: > I have completed the work on custom

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Scott Deboy
Are these serialization-wise going to be the same as standard levels? Receivers and apps like Chainsaw would benefit from not requiring the originating level class be included in the classpath. I'm thinking about socketreceiver and to a lesser extent logfilepatternreceiver. Scott On Jan 26, 201

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Scott Deboy
So I assume we could build on this by adding the ability to generate these custom levels from the config, with no user provided class required? On Jan 26, 2014 12:58 AM, "Ralph Goers" wrote: > > I have completed the work on custom levels. It uses a variation of Nick’s “extensible enum” class.

Re: Enums and Custom Levels

2014-01-26 Thread Remko Popma
> From: Remko Popma > Date:01/26/2014 00:13 (GMT-05:00) > To: Log4J Developers List > Subject: Re: Enums and Custom Levels > > Ralph, > I copied Nick's code _as is_ and had no compile errors. > The class is abstract, but instances are defined in the static bloc

Re: Enums and Custom Levels

2014-01-26 Thread Gary Gregory
Enums and Custom Levels Ralph, I copied Nick's code _as is_ and had no compile errors. The class is abstract, but instances are defined in the static block as: OFF = new Level("OFF", 0) {}; // note the {}: this creates an anonymous concrete subclass I agree that read access needs t

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Remko Popma
I'm very curious! Can't wait to see it. Go for it! On Sunday, January 26, 2014, Ralph Goers wrote: > I have completed the work on custom levels. It uses a variation of Nick’s > “extensible enum” class. The major difference with what he proposed is > that the custom enums must be declared in a

Re: Enums and Custom Levels - completed.

2014-01-26 Thread Ralph Goers
I have completed the work on custom levels. It uses a variation of Nick’s “extensible enum” class. The major difference with what he proposed is that the custom enums must be declared in a class annotated with @Plugin(name=“” category=“Level”) for them to be usable during configuration. A

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
They can already do the same thing with loggers right? Scott On Jan 25, 2014 10:19 PM, "Ralph Goers" wrote: > A malicious app could do > > for (int i=0; i < 10; ++i) { > new Level(“Level” + i, 1000 + i){}; > } > > Sure idiots can do lots of bad things but I don’t think Levels should be > q

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
It was a lot harder when each custom extension was an enum implementing an interface. There was no way to do a new on it. Ralph > On Jan 25, 2014, at 10:33 PM, Remko Popma wrote: > > Hm... > Doesn't it become nearly impossible to protect against malicious intent, the > moment we make it exten

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Hm... Doesn't it become nearly impossible to protect against malicious intent, the moment we make it extensible? On Sunday, January 26, 2014, Ralph Goers wrote: > A malicious app could do > > for (int i=0; i < 10; ++i) { > new Level(“Level” + i, 1000 + i){}; > } > > Sure idiots can do lots

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
A malicious app could do for (int i=0; i < 10; ++i) { new Level(“Level” + i, 1000 + i){}; } Sure idiots can do lots of bad things but I don’t think Levels should be quite that flexible. Ralph On Jan 25, 2014, at 9:39 PM, Remko Popma wrote: > I don't think client code can do new Level(

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
I wanted to have my cake and eat it too. I want the standard levels to be part of an enumeration so I can use switch. The way the code was written I couldn’t do that. I’ve figured out another way. I have a StdLevel enum embedded in the Level class. Ralph On Jan 25, 2014, at 9:39 PM, Remko

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Apologies for thinking out loud and not being clear. Code generation can probably be made to work with either "real" enums or the extensible enums approach. The mechanism may differ but either should be possible. So from that point of view, no preference either way. Again apologies for the confusio

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
*static Map in the extensible enum class On Sun, Jan 26, 2014 at 2:56 PM, Remko Popma wrote: > After thinking about it some more, the code generation could just access > the static Map in the extensible enums class and find out what instances > are registered. That would work but assumes that t

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
After thinking about it some more, the code generation could just access the static Map in the extensible enums class and find out what instances are registered. That would work but assumes that the configuration (or at least the initialization of the static Map in Levels) is complete before code g

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Did you mean that a custom Level implementation cannot extend StdLevel? So a custom Level implementation would need to include the levels defined in StdLevel (DEBUG, INFO, ...) in addition to the custom levels. I think I see now. How much of a problem is this though? Or, do we need to start thinki

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I don't think client code can do new Level(){} as the constructor requires String and int arguments. By the way, I am unclear on what went wrong with the enum approach you originally took. You said: StdLevel isn’t a Level because it can’t extend it if it is an enum, so I can’t initialize the l

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Out of curiosity, what exactly is the benefit of declaring the class abstract when it has a protected constructor? It seems like all you are accomplishing is making the instantiation syntax uglier. It also bothers me that open code can just do a new Level(){} - which will do nothing but cause p

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Yeah, I missed the {} as I modified the class before I tried to compile it. You can’t just use an AtomicInteger because you might be adding a duplicate to the map, in which case you have incorrectly incremented the ordinal. I used simple synchronization. Unfortunately, because the extended lev

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Ralph, I copied Nick's code _as is_ and had no compile errors. The class is abstract, but instances are defined in the static block as: OFF = new Level("OFF", 0) {}; // note the {}: this creates an anonymous concrete subclass I agree that read access needs to be synchronized as well, not just writ

Re: Enums and Custom Levels

2014-01-25 Thread Nicholas Williams
Ralph, if you're getting compile errors with that code, A) there's a copy-paste/transposition error, or B) there's something wrong with your (non-standard?) compiler. Given: abstract class A { ... } This is perfectly legal in Java 5+: A a = new A() { }; That's an anonymous inner class extendi

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
the Logger interface, it was to add > code to a user's class that wraps a logger. > > G > > > Original message > From: Remko Popma > Date:01/25/2014 21:51 (GMT-05:00) > To: Log4J Developers List > Subject: Re: Enums and Custom Levels &

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
As I am working on this I just want to point out a number of issues with the code below: 1. The class is abstract. The static block is doing a bunch of new Level() invocations which obviously generate compile errors on an abstract class. I had to make it be a non-abstract class. 2. As I pointe

Re: Enums and Custom Levels

2014-01-25 Thread Gary Gregory
My idea was _not_ to add byte codes to the Logger interface, it was to add code to a user's class that wraps a logger.  G Original message From: Remko Popma Date:01/25/2014 21:51 (GMT-05:00) To: Log4J Developers List Subject: Re: Enums and Custom Levels I'

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Yeah, I took another 5 minutes and thought about it. A proxy isn’t the full answer as somehow we need to create the method signatures for compile time. I’ve done that before from database data to generate an interface but this is a little different. Ralph On Jan 25, 2014, at 7:07 PM, Remko Po

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I mean, not sure whether to use Proxy or generate code or something else, but hopefully get really close to the ease-of-use of the current Logger interface... On Sun, Jan 26, 2014 at 12:06 PM, Remko Popma wrote: > I'm not sure how close we can get to what we have now, but yes, that was > what I

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I'm not sure how close we can get to what we have now, but yes, that was what I had in mind... On Sun, Jan 26, 2014 at 12:00 PM, Ralph Goers wrote: > Wow - I had never thought about using a Java Proxy to implement all those > methods before. That would be a piece of cake. > > Ralph > > On Jan 2

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Wow - I had never thought about using a Java Proxy to implement all those methods before. That would be a piece of cake. Ralph On Jan 25, 2014, at 6:51 PM, Remko Popma wrote: > I've started to think about how to implement Gary's idea to use these custom > levels to generate code that would a

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
Great! That plus support for defining custom levels from the config (with no custom class required) would mean we would have found a solution that I believe resolves everyone's issues. Scott On Jan 25, 2014 6:52 PM, "Remko Popma" wrote: > I've started to think about how to implement Gary's idea

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I've started to think about how to implement Gary's idea to use these custom levels to generate code that would add methods to the Logger interface, but I think I'll wait a little to see what form the custom levels take. On Sun, Jan 26, 2014 at 11:45 AM, Remko Popma wrote: > These are the switc

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
These are the switches I found: * log4j-1.2-api: org.apache.log4j.Category - just FYI, it looks like this switch is missing the FATAL level... is this a bug? * log4j-api: org.apache.logging.log4j.status.StatusLogger * log4j-core: org.apache.logging.log4j.core.net.Severity * log4j-core: org.apache.l

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
I am not sure what you mean by this. I have already succeeded in adding custom level names to the configuration and making them be valid. I am just trying to clean it up a bit based on what Nick is suggesting. Ralph On Jan 25, 2014, at 6:30 PM, Scott Deboy wrote: > There's no way to add sup

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Actually, we can use switch in all the places it is currently being used. They are all places where we are converting between our levels to a Level or Severity from some other framework. I handled that by first mapping custom levels to the closest standard level and then using the switch state

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
There's no way to add support for users to define level entries (name and value pairs as a new element in the config) and have us do the work to make those valid? That would get get rid of my request for additional levels, right? On Jan 25, 2014 6:15 PM, "Ralph Goers" wrote: > The class is needed

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
You can't "switch" anymore because custom levels means you're dealing with an unknown quantity of levels. You'll have to look them up in a registry/map. That's the trade off of an extensible system. On Jan 25, 2014 8:13 PM, "Ralph Goers" wrote: > Rats. StdLevel isn’t a Level because it can’t ext

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
The class is needed because it is a name and a value (two items) that has to be represented as a single parameter to Logger methods. Using raw int or String is not a good alternative. Ralph On Jan 25, 2014, at 4:54 PM, Scott Deboy wrote: > If levels are just a name and a value why require a

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Rats. StdLevel isn’t a Level because it can’t extend it if it is an enum, so I can’t initialize the levels using that. So no switch statements if we go this way. I’ll keep looking at it but that makes this solution less appealing to me. Ralph On Jan 25, 2014, at 6:05 PM, Ralph Goers wrote:

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Sure, I can take a look at doing it that way. But it is going to have many of the same problems to implement as to what I just finished doing - except that I won’t need the Levels class or Levels interface. The one downside to this approach is that there are 4 or 5 places where Level is used in

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
Nick, I think because your solution is considered "old style" enums. I don't know anyone making those kind of enums anymore since JDK 1.5 gave us an official "enum" keyword. Using that and interfaces is preferred, I think. On Sat, Jan 25, 2014 at 7:32 PM, Nicholas Williams < nicho...@nicholaswill

Re: Enums and Custom Levels

2014-01-25 Thread Nicholas Williams
I actually do object I think. It sounds like a significantly more convoluted approach than the extensible enum. With the extensible enum, new levels are immediately discovered, serialization works automatically, and extenders don't have to do any extra work in the constructor. Why are we making

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
In any event, I'd like to thank the entire Log4J Developer community here for hearing out my interface idea without biting my head off -- after all, it's a "big" change near a GA release :-) It was also nice knowing there exists a place where a serious technical debate can remain cordial. Kudos. An

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
If levels are just a name and a value why require a class at all? What about just having it defined in the configuration. On Jan 25, 2014 4:37 PM, "Ralph Goers" wrote: > Because we don't know the class name that the Level belongs to. It is > referenced in the configuration just as "DIAG", not >

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Because we don’t know the class name that the Level belongs to. It is referenced in the configuration just as “DIAG”, not “org.apache.logging.test.ExtendedLevel.DIAG”. In any case I fixed it. I just annotated the new Level as a Plugin and then look up all the Level plugins in BaseConfiguratio

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Would it be an option to require that the custom level class package is mentioned in the Configuration packages="..." attribute? On Sun, Jan 26, 2014 at 9:26 AM, Paul Benedict wrote: > If you made it a requirement for the constructor to register, why not just > instantiate each level as you enc

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
If you made it a requirement for the constructor to register, why not just instantiate each level as you encounter it in the config? On Sat, Jan 25, 2014 at 6:06 PM, Ralph Goers wrote: > Hmm. It seems I am going to have to do something to force the registration > as the custom level class hasn’t

  1   2   >