expandTags

String-replaces <tags> in a string with the results from calls to KamelosoLogger *tint methods. Also works with dstrings and wstrings. Overload that does not take a strip Flag.

  1. auto expandTags(T line, LogLevel baseLevel, bool strip)
  2. auto expandTags(T line, LogLevel baseLevel)
    @safe
    expandTags
    (
    T
    )
    (
    const T line
    ,)

Parameters

line T

A line of text, presumably with <tags>.

baseLevel LogLevel

The base LogLevel to fall back to on </> tags.

Return Value

Type: auto

The passed line but with any <tags> replaced with ANSI colour sequences. The original string is passed back if there was nothing to replace.

Examples

import kameloso.common : logger;
import std.conv : text, to;

{
    immutable line = "This is a <l>log</> line.";
    immutable replaced = line.expandTags(LogLevel.off);
    immutable expected = text("This is a ", logger.logtint, "log", logger.offtint, " line.");
    assert((replaced == expected), replaced);
}