std.experimental.logger formal review round 3
Sönke Ludwig via Digitalmars-d
digitalmars-d at puremagic.com
Thu Oct 2 13:15:37 PDT 2014
I still think that there should be the two predefined log levels "debug"
(for developer related diagnostics) and "diagnostic" (for end user
related diagnostics) between "trace" and "info". This is important for
interoperability of different libraries, so that they have predictable
debug output.
But independent of that, there should really be a function for safely
generating the user defined intermediate log levels, maybe like this:
LogLevel raiseLevel(LogLevel base_level, ubyte increment)
{
assert(base_level is a valid base level);
assert(base_level + increment smaller than the next base level);
return cast(LogLevel)(base_level + increment);
}
// ok
enum notice = raiseLevel(LogLevel.info, 16);
// error, overlaps with the next base level
enum suspicious = raiseLevel(LogLevel.info, 32);
Casting to an enum type is a pretty blunt operation, so it should at
least be made as safe as possible.
More information about the Digitalmars-d
mailing list