Is Haskell available for use with journal accessible color?

I would like to change the color of the output of the log message to the terminal depending on the log level, topic, etc.,

The only logger I found that does this in Haskell is part of the xmonad-contrib package, but I do not want to accept the dependency on it, since it is quite large.

I know that Yesod comes in color, but itโ€™s not obvious to me how to make it work with the magazine outside of the Yesod web application.

I looked at hslogger , which seems to be very similar to System.Log.Logger , but none of them have color support out of the box.

hslogger expands with custom LogHandlers , maybe someone implemented it with color support?

Are there any alternatives to registering with Haskell, which I still haven't noticed?

EDIT:

Following Don Stuartโ€™s advice, I implemented my own log handler , which works with hslogger and ansi-c to enable terminal logging in color.

+6
source share
2 answers

As of May 2012, the available logging libraries for Haskell are:

And a few more specialized ones:

  • greg-client - client for the distributed registration system greg
  • fast-logger - a logging system optimized for fast I / O

There is no support for ansi terminal color output. There are several libraries for coloring ansi, so they should not be added too complicated. For instance.

+5
source

If you want to see another example of a color logger, look at Network.Wai.Middleware.RequestLogger (logStdoutDev) in the wai-extra package. This changes color per request, but this should serve as a good example.

0
source

Source: https://habr.com/ru/post/914897/


All Articles