dlang-community / mecca

Weka.IO's userland OS
Boost Software License 1.0
64 stars 16 forks source link

Configurable logging #10

Open jacob-carlborg opened 6 years ago

jacob-carlborg commented 6 years ago

Currently the recator (and possible other parts of the library) is doing quite a lot of logging. It would be nice if the logging could be configurable. To start with to be able to disable/enable the different log levels, ideally both at compile time and run time.

baruch commented 5 years ago

The logging is intended as an implementation-dependent placeholder, as such, we wouldn't want to complicate it too much and in fact, for our internal use we replace it and hook it up to our internal tracing facility. We expect others to do the same for their logging needs so if you want a runtime configurable logging you can implement it in your own logging facility and if you want it at compile time you can just implement null functions for the levels you don't want to care about.

Does that make sense?

jacob-carlborg commented 5 years ago

for our internal use we replace it and hook it up to our internal tracing facility

That's what I thought.

We expect others to do the same for their logging needs.

The problem though is that there is no straightforward way to do this when using Dub. I haven't at least figured out a good way to do it. I'm guessing Weka doesn't used Dub.

It's also not clear what the interface need to be. I can read the existing implementation. DEBUG, INFO, WARN and ERROR are pretty clear. But META, what is that used for? Then there's LOG_EXCEPTION and LOG_TRACEBACK as well, which are also not as clear. Reading the implementation there's a level associated with each of the above mentioned functions. But it's not clear how to order the log levels. Usually in a logging framework it's possible to specify a severity level: anything below will not be logged but anything above will be logged. It's not clear how to do that with the given interface. Is META more or less severe than INFO? In the current implementation log level is basically only used to color the output, so the order doesn't really matter.

SingingBush commented 1 year ago

How about removing mecca.log and instead use std.logger which would make it convenient for users to either use one of the loggers provided in the standard library, implement their own, or use one of the dub packages that implement std.logger.core.Logger

jacob-carlborg commented 1 year ago

How about removing mecca.log and instead use std.logger

Hmm, I don't know. So far, IIRC, Phobos is not used in mecca. I feel it goes against the philosophy of mecca.