-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging #8
Comments
Agreed, but I'm not sure the |
You're right, they don't need the same API, but I think there does need to be some commonality in how they're configured. For example, the |
But that's the point I was trying to make, I don't think the |
I suffered this issue a little when refactoring some of the .src archive generation code. Having a logging abstraction in ceylon-common would definitely help to decouple a lot of stuff which sometimes is tied to, say, javac, just because it uses javac logging directly instead of some API (which can have a javac-logging backend for ceylonc). So +1 for this; there should be a very simple logging API in ceylon-common, with a simple implementation which uses |
Adding a logging API to ceylon-common should be simple enough. A default implementation should also be relatively simple. More problematic is how we're going to configure it, while not creating some over-complex monster. I would be happy with:
I still don't know about the default message format, or things like logging categories. |
Issues with this: * No tests yet, since it's for discussion. * Being able to change the threshold level of the DefaultLog is all very well but that only works if the default log is the one being used. OTOH, we need to support things like `ceylon compile --verbose`. * The same points as are made in #9 also apply to logging., so having a single place (LogFactory.setFactory()) where 'the' LogFactory defined for a whole application isn't ideal.
To push discussion along a bit, I've created a 'log' branch with a very simplistic sketch of what be a solution. The commit message for 45cae91 includes a few issues, but I'm sure there are plenty more. |
I think we should copy the design of the standard Java logging APIs a bit more, especially the part where the String you pass is a format string and then you can pass several arguments to be used by it. This makes sure that the logging is as efficient as possible when not used. |
+1 |
The alternative would be log4j-style I see that those APIs make a distinction between 'message parameters' and exceptions, presumably so they can dump the exception's stacktrace, not just include its Do we also support the String message also being a key into a message catalog? If so, how would we find the catalog? If not, the facade is a leaky abstraction because depending on the implementation in use you'd either get a helpful message or rather less helpful message key. |
And what I'd really suggest is to just use an existing interface like http://www.slf4j.org/apidocs/org/slf4j/Logger.html , it's a very popular package, it's tiny and at the same time very flexible if we ever want to use other implementations (like logback). |
I've used it before and I liked it in those situations. I think using it would solve the API part. I'm not certain about the configuration aspect though. The tool scripts could just include an appropriate backend jar in their classpath, but it would be legitimate for an application to want to have multiple compiler instances (for example) and direct the log messages to different places. Similarly I worry about the fact that the (Btw: I fully concede that the simple API I wrote doesn't address this either) |
I think the slf4j API is flexible enough so we can adjust it to that kind of situation in the future. Let's start simple and leave the complex situations for when we get to them, I think the unification of all loggers we currently use is already big enough of a job :) |
Moving to M6 |
Currently a whole bunch of things each use their own logging:
Logger
interface. Because everything else already does its own logging there are already with 7 implementations (delegating to JUL,System.err
, javacLog
, plus a couple of No-op loggers)ceylon.logging
module.It seems like ceylon-common is a good place to define a common API (and some implementations).
The text was updated successfully, but these errors were encountered: