std.experimental.logger formal review round 3

Robert burner Schadek via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 5 09:49:59 PDT 2014


On Thursday, 2 October 2014 at 20:15:32 UTC, Sönke Ludwig wrote:
> 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.

from log4d
/// Aliases for debugX and fineX functions
alias debug1  = defaultLogFunction!(Log4DLogger.LOG_LEVEL_DEBUG1);
alias debug2  = defaultLogFunction!(Log4DLogger.LOG_LEVEL_DEBUG2);
alias debug3  = defaultLogFunction!(Log4DLogger.LOG_LEVEL_DEBUG3);

but adding a raiseLevel function should be no problem


More information about the Digitalmars-d mailing list