Consider a log that write to both stdout and file, we need a handler that write to both, the idea is similar to io.MultiWriter
The reason we can't use io.MultiWriter directly is we also want different format for different output. i.e. stdout, I want to use a human readable format, for file I want to use machine readable format, further more I can even log to multiple files with different format, i.e. log.txt and log.json
Ref
Consider a log that write to both stdout and file, we need a handler that write to both, the idea is similar to io.MultiWriter
The reason we can't use
io.MultiWriterdirectly is we also want different format for different output. i.e. stdout, I want to use a human readable format, for file I want to use machine readable format, further more I can even log to multiple files with different format, i.e. log.txt and log.jsonRef
MultiHandler