|
1 | 1 | abstract type AbstractMode end
|
2 | 2 | struct NoTransformations <: AbstractMode end
|
3 | 3 | struct Squash <: AbstractMode end
|
| 4 | +struct MDown <: AbstractMode end |
4 | 5 |
|
5 | 6 | struct MiniLogger{AM <: AbstractMode, IOT1 <: IO, IOT2 <: IO, DFT <: DateFormat} <: AbstractLogger
|
6 | 7 | io::IOT1
|
@@ -29,6 +30,8 @@ function getmode(mode::Symbol)
|
29 | 30 | return NoTransformations()
|
30 | 31 | elseif mode == :squash
|
31 | 32 | return Squash()
|
| 33 | + elseif mode == :markdown |
| 34 | + return MDown() |
32 | 35 | end
|
33 | 36 | end
|
34 | 37 |
|
@@ -57,6 +60,7 @@ Supported keyword arguments include:
|
57 | 60 | * `message_mode` (default: `:squash`): choose how message is transformed before being printed out. Following modes are supported:
|
58 | 61 | * `:notransformations`: message printed out as is, without any extra transformations
|
59 | 62 | * `:squash`: message is squashed to a single line, i.e. all `\\n` are changed to ` ` and `\\r` are removed.
|
| 63 | + * `:markdown`: message is treated as if it is written in markdown |
60 | 64 | * `flush` (default: `true`): whether to `flush` IO stream for each log message. Flush behaviour also affected by `flush_threshold` argument.
|
61 | 65 | * `flush_threshold::Union{Integer, TimePeriod}` (default: 0): if this argument is nonzero and `flush` is `true`, then `io` is flushed only once per `flush_threshold` milliseconds. I.e. if time between two consecutive log messages is less then `flush_threshold`, then second message is not flushed and will have to wait for the next log event.
|
62 | 66 | * `dtformat` (default: "yyyy-mm-dd HH:MM:SS"): if `datetime` parameter is used in `format` argument, this dateformat is applied for output timestamps.
|
@@ -122,6 +126,7 @@ function _showmessage(io, msg, ::Squash)
|
122 | 126 | print(io, " ", replace(msglines[i], "\r" => ""))
|
123 | 127 | end
|
124 | 128 | end
|
| 129 | +_showmessage(io, msg, ::MDown) = show(io, MIME"text/plain"(), Markdown.parse(msg)) |
125 | 130 | _showmessage(io, msg, ::NoTransformations) = print(io, msg)
|
126 | 131 |
|
127 | 132 | showmessage(io, msg, mode) = _showmessage(io, msg, mode)
|
|
0 commit comments