-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
Yaml configuration support #114
Comments
I prefer properties files as a primary and official configuration of tinylog. Multiply ways of configuration will make it much more difficult to keep the documentation of tinylog up-to-date and complete for all configuration options. However, I would accept a third party project and I can imagine to make the configuration of tinylog pluggable to make it easy to develop such configuration extensions as your requested YAML support. |
I agree with pmwmedia that there is little need for non property configuration. However, since pmwmedia suggested a pluggable service for configuration - and I ran out of own issues to implement ... :-) I had a quick look and hack at a service loader for the See the next comment for my suggestion for an implementation. Please have a look at it and see whether this would be useful too have or what other approach would be preferable. |
Introduce a new SERVICE: for the new interface
Here then an implementation of the standard tiny log propertiy loader as it was before in
the main change then in the load method of
To make it easier for other loaders we should have a bit more public access to some former package elements: That was all needed to get another loader running. |
There is one conceptual issue: Since one can not really configure the configuration itself (except with system properties or so but you don't really want to enforce that) one cannot really determine which property loader to use.
I think the first is sufficient though. All others are complicated with not so much gain. |
@Git5000 I really like your concept! It is very flexible and generic. Personally, I prefer a priority property for determining which |
Ok, sounds good. Just a few more questions:
|
Actually, I thought about a priority getter in the
Higher numbers first (same as thread priorities in Java)
Good idea :) PS: Maybe |
Yes I thought this first too (in my initial suggestion). I understood your reply then as a property inside the files. This I actually liked better than my first idea. The configuration is then on file level not code level. So you load all files and keep the one with the highest priority. A disadvantage is of course that you load all files (but in practise this is one or two only anyway). Advantage is that you can set this property independently of the code inside the actual files. Of course, in practise I cannot really see that someone will really load properties from JSON and YAML and Java properties. So you should only have one loader doing any loading anyway.
If you have a priority getter in the code the use case is probably only to switch off the tinylog configuration itself and use your own (single) loader. Then maybe a boolean getter would suffice? But of course in case we miss a use case this takes away flexibility. So what should we do? :-)
ok
Ok |
@Git5000 Sorry for my delayed responses. Currently, I'm on vacations at the Baltic Sea. Mainly, I'm working on Java EE and JSF projects in my job. In this context, I'm used to call getters (+ setters) as properties. Sorry for the confusion! My main goal is to keep the tinylog code and configuration files as simple as possible. If the priority has to be configured directly in the configuration files, what will happen if there are multiple configuration files but the user hasn't set any priorities in these files? In the latest tinylog version, it is already possible to define priorities via the configuration file names (tinylog-dev.properies, tinylog-test.properties, and tinylog.properties). Actually, I see loading of merged configuration as confusing and I can't imagine a real world use case for it. I prefer defining the priority via a getter or always prefer a custom |
Don't worry about a delayed response. I am actually amazed about the speed of your responses. And you certainly should enjoy your holiday :-)
I fullly agree. That the library is simple, fast, well designed but yet capable is the main reason I really like and use it.
You right that it should not be confusing and kept simple. Generally, the discussion here in the forum is very useful and I think we always iterate to a good solution. I played around a bit with the lastest ideas and I think the best solution is indeed to always prefer a custom loader (i.e. no additional property or method in the interface). With having a system property to select the loader, there is still all flexibility to select any loaders you would want, internal or custom. The loader code becomes small and good too. The code then would looks like:
You think that is ok? Is the property name "tinylog.configurationLoader" ok? |
The concept works actually very nicely :-)
PS: I can later on make a small repository on my Github page with the Tinylog extra stuff where I can upload these loaders as example. |
I fully agree 👍 Discussing ideas together is a very efficient way to find the best solutions in an iterative way. I'm very glad about your great contribution to tinylog :)
Yes, I would choose the same property name. I just prefer to use a lower case Do you use tinylog's service loader implementation org.tinylog.configuration.ServiceLoader? If the class names are Your YAML example looks very straight forward and clearer than a properties file. I like it :)
Sounds very great :) I would announce your repository on tinylog's news site and link it in the documentation. |
Yes I use the service loader. Interesting option to load them also the short way. Currently, it does not work but I think I named the classes wrong. I will change that and since you seem ok with the overall changes I will slowly prepare a pull request for review. I suppose there will be a few iterations on the code too then. |
Add optional yaml support for config please
The text was updated successfully, but these errors were encountered: