-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Util.Loggers
-- Copyright   :  (c) Brent Yorgey, Wirt Wolff
-- License     :  BSD-style (see LICENSE)
--
-- Maintainer  :  <byorgey@gmail.com>
-- Stability   :  unstable
-- Portability :  unportable
--
-- A collection of simple logger functions and formatting utilities
-- which can be used in the 'XMonad.Hooks.DynamicLog.ppExtras' field of
-- a pretty-printing status logger format. See "XMonad.Hooks.DynamicLog"
-- for more information.
-----------------------------------------------------------------------------

module XMonad.Util.Loggers (
    -- * Usage
    -- $usage

      Logger

    -- * System Loggers
    -- $system
    , aumixVolume
    , battery
    , date
    , loadAvg
    , maildirNew, maildirUnread
    , logCmd , logFileCount

    -- * XMonad Loggers
    -- $xmonad
    , logCurrent, logLayout, logTitle

    -- * Formatting Utilities
    -- $format
    , onLogger
    , wrapL, fixedWidthL
    , logSp, padL
    , shortenL
    , dzenColorL, xmobarColorL

    , (<$>)

  ) where

import XMonad (liftIO)
import XMonad.Core
import qualified XMonad.StackSet as W
import XMonad.Hooks.DynamicLog
import XMonad.Util.Font (Align (..))
import XMonad.Util.NamedWindows (getName)

import Control.Applicative ((<$>))
import Control.Exception as E
import Data.List (isPrefixOf, isSuffixOf)
import Data.Maybe (fromMaybe)
import Data.Traversable (traverse)
import System.Directory (getDirectoryContents)
import System.IO
import System.Locale
import System.Process (runInteractiveCommand)
import System.Time

econst :: Monad m => a -> IOException -> m a
econst :: a -> IOException -> m a
econst = m a -> IOException -> m a
forall a b. a -> b -> a
const (m a -> IOException -> m a)
-> (a -> m a) -> a -> IOException -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return

-- $usage
-- Use this module by importing it into your @~\/.xmonad\/xmonad.hs@:
--
-- > import XMonad.Util.Loggers
--
-- Then, add one or more loggers to the
-- 'XMonad.Hooks.DynamicLog.ppExtras' field of your
-- 'XMonad.Hooks.DynamicLoc.PP', possibly with extra formatting .
-- For example:
--
-- >   -- display load averages and a pithy quote along with xmonad status.
-- >   , logHook = dynamicLogWithPP $ def {
-- >                  ppExtras = [ padL loadAvg, logCmd "fortune -n 40 -s" ]
-- >                }
-- >   -- gives something like " 3.27 3.52 3.26 Drive defensively.  Buy a tank."
--
-- See the formatting section below for another example using
-- a @where@ block to define some formatted loggers for a top-level
-- @myLogHook@.
--
-- Loggers are named either for their function, as in 'battery',
-- 'aumixVolume', and 'maildirNew', or are prefixed with \"log\" when
-- making use of other functions or by analogy with the pp* functions.
-- For example, the logger version of 'XMonad.Hooks.DynamicLog.ppTitle'
-- is 'logTitle', and 'logFileCount' loggerizes the result of file
-- counting code.
--
-- Formatting utility names are generally as short as possible and
-- carry the suffix \"L\". For example, the logger version of
-- 'XMonad.Hooks.DynamicLog.shorten' is 'shortenL'.
--
-- Of course, there is nothing really special about these so-called
-- \"loggers\": they are just @X (Maybe String)@ actions.  So you can
-- use them anywhere you would use an @X (Maybe String)@, not just
-- with DynamicLog.
--
-- Additional loggers welcome!



-- | 'Logger' is just a convenient synonym for @X (Maybe String)@.
type Logger = X (Maybe String)

-- $system

-- | Get the current volume with @aumix@. <http://jpj.net/~trevor/aumix.html>
aumixVolume :: Logger
aumixVolume :: Logger
aumixVolume = String -> Logger
logCmd String
"aumix -vq"

-- | Get the battery status (percent charge and charging\/discharging
--   status). This is an ugly hack and may not work for some people.
--   At some point it would be nice to make this more general\/have
--   fewer dependencies (assumes @\/usr\/bin\/acpi@ and @sed@ are installed.)
battery :: Logger
battery :: Logger
battery = String -> Logger
logCmd String
"/usr/bin/acpi | sed -r 's/.*?: (.*%).*/\\1/; s/[dD]ischarging, ([0-9]+%)/\\1-/; s/[cC]harging, ([0-9]+%)/\\1+/; s/[cC]harged, //'"

-- | Get the current date and time, and format them via the
--   given format string.  The format used is the same as that used
--   by the C library function strftime; for example,
--   @date \"%a %b %d\"@ might display something like @Tue Feb 19@.
--   For more information see something like
--   <http://www.cplusplus.com/reference/clibrary/ctime/strftime.html>.
date :: String -> Logger
date :: String -> Logger
date String
fmt = IO (Maybe String) -> Logger
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO (Maybe String) -> Logger) -> IO (Maybe String) -> Logger
forall a b. (a -> b) -> a -> b
$ do CalendarTime
cal <- (IO ClockTime
getClockTime IO ClockTime -> (ClockTime -> IO CalendarTime) -> IO CalendarTime
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ClockTime -> IO CalendarTime
toCalendarTime)
                   Maybe String -> IO (Maybe String)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe String -> IO (Maybe String))
-> (String -> Maybe String) -> String -> IO (Maybe String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe String
forall a. a -> Maybe a
Just (String -> IO (Maybe String)) -> String -> IO (Maybe String)
forall a b. (a -> b) -> a -> b
$ TimeLocale -> String -> CalendarTime -> String
formatCalendarTime TimeLocale
defaultTimeLocale String
fmt CalendarTime
cal

-- | Get the load average.  This assumes that you have a
--   utility called @\/usr\/bin\/uptime@ and that you have @sed@
--   installed; these are fairly common on GNU\/Linux systems but it
--   would be nice to make this more general.
loadAvg :: Logger
loadAvg :: Logger
loadAvg = String -> Logger
logCmd String
"/usr/bin/uptime | sed 's/.*: //; s/,//g'"

-- | Create a 'Logger' from an arbitrary shell command.
logCmd :: String -> Logger
logCmd :: String -> Logger
logCmd String
c = IO (Maybe String) -> Logger
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io (IO (Maybe String) -> Logger) -> IO (Maybe String) -> Logger
forall a b. (a -> b) -> a -> b
$ do (Handle
_, Handle
out, Handle
_, ProcessHandle
_) <- String -> IO (Handle, Handle, Handle, ProcessHandle)
runInteractiveCommand String
c
                   (String -> Maybe String) -> IO String -> IO (Maybe String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Maybe String
forall a. a -> Maybe a
Just (Handle -> IO String
hGetLine Handle
out) IO (Maybe String)
-> (IOException -> IO (Maybe String)) -> IO (Maybe String)
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` Maybe String -> IOException -> IO (Maybe String)
forall (m :: * -> *) a. Monad m => a -> IOException -> m a
econst Maybe String
forall a. Maybe a
Nothing
                   -- no need to waitForProcess, we ignore SIGCHLD

-- | Get a count of filtered files in a directory.
-- See 'maildirUnread' and 'maildirNew' source for usage examples.
logFileCount :: FilePath          -- ^ directory in which to count files
             -> (String -> Bool)  -- ^ predicate to match if file should be counted
             -> Logger
logFileCount :: String -> (String -> Bool) -> Logger
logFileCount String
d String -> Bool
p = do
    [String]
c <- IO [String] -> X [String]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO ( String -> IO [String]
getDirectoryContents String
d)
    let n :: Int
n = [String] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([String] -> Int) -> [String] -> Int
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
Prelude.filter String -> Bool
p [String]
c
    case Int
n of
        Int
0 -> Maybe String -> Logger
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe String
forall a. Maybe a
Nothing
        Int
_ -> Maybe String -> Logger
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe String -> Logger) -> Maybe String -> Logger
forall a b. (a -> b) -> a -> b
$ String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String) -> String -> Maybe String
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show Int
n

-- | Get a count of unread mails in a maildir. For maildir format
-- details, to write loggers for other classes of mail, see
-- <http://cr.yp.to/proto/maildir.html> and 'logFileCount'.
maildirUnread :: FilePath -> Logger
maildirUnread :: String -> Logger
maildirUnread String
mdir = String -> (String -> Bool) -> Logger
logFileCount (String
mdir String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"/cur/") (String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isSuffixOf String
",")

-- | Get a count of new mails in a maildir.
maildirNew :: FilePath -> Logger
maildirNew :: String -> Logger
maildirNew String
mdir = String -> (String -> Bool) -> Logger
logFileCount (String
mdir String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"/new/") (Bool -> Bool
not (Bool -> Bool) -> (String -> Bool) -> String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isPrefixOf String
".")

-- $xmonad
--
-- A very small sample of what you can log since you have access to X. For
-- example you can loggerize the number of windows on each workspace, or
-- titles on other workspaces, or the id of the previously focused workspace....

-- | Get the title (name) of the focused window.
logTitle :: Logger
logTitle :: Logger
logTitle = (WindowSet -> Logger) -> Logger
forall a. (WindowSet -> X a) -> X a
withWindowSet ((WindowSet -> Logger) -> Logger)
-> (WindowSet -> Logger) -> Logger
forall a b. (a -> b) -> a -> b
$ (Window -> X String) -> Maybe Window -> Logger
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((NamedWindow -> String) -> X NamedWindow -> X String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap NamedWindow -> String
forall a. Show a => a -> String
show (X NamedWindow -> X String)
-> (Window -> X NamedWindow) -> Window -> X String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Window -> X NamedWindow
getName) (Maybe Window -> Logger)
-> (WindowSet -> Maybe Window) -> WindowSet -> Logger
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> Maybe Window
forall i l a s sd. StackSet i l a s sd -> Maybe a
W.peek

-- | Get the name of the current layout.
logLayout :: Logger
logLayout :: Logger
logLayout = (WindowSet -> Logger) -> Logger
forall a. (WindowSet -> X a) -> X a
withWindowSet ((WindowSet -> Logger) -> Logger)
-> (WindowSet -> Logger) -> Logger
forall a b. (a -> b) -> a -> b
$ Maybe String -> Logger
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe String -> Logger)
-> (WindowSet -> Maybe String) -> WindowSet -> Logger
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String)
-> (WindowSet -> String) -> WindowSet -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> String
forall i a sid sd. StackSet i (Layout Window) a sid sd -> String
ld
  where ld :: StackSet i (Layout Window) a sid sd -> String
ld = Layout Window -> String
forall (layout :: * -> *) a.
LayoutClass layout a =>
layout a -> String
description (Layout Window -> String)
-> (StackSet i (Layout Window) a sid sd -> Layout Window)
-> StackSet i (Layout Window) a sid sd
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Workspace i (Layout Window) a -> Layout Window
forall i l a. Workspace i l a -> l
W.layout (Workspace i (Layout Window) a -> Layout Window)
-> (StackSet i (Layout Window) a sid sd
    -> Workspace i (Layout Window) a)
-> StackSet i (Layout Window) a sid sd
-> Layout Window
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Screen i (Layout Window) a sid sd -> Workspace i (Layout Window) a
forall i l a sid sd. Screen i l a sid sd -> Workspace i l a
W.workspace (Screen i (Layout Window) a sid sd
 -> Workspace i (Layout Window) a)
-> (StackSet i (Layout Window) a sid sd
    -> Screen i (Layout Window) a sid sd)
-> StackSet i (Layout Window) a sid sd
-> Workspace i (Layout Window) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackSet i (Layout Window) a sid sd
-> Screen i (Layout Window) a sid sd
forall i l a sid sd. StackSet i l a sid sd -> Screen i l a sid sd
W.current

-- | Get the name of the current workspace.
logCurrent :: Logger
logCurrent :: Logger
logCurrent = (WindowSet -> Logger) -> Logger
forall a. (WindowSet -> X a) -> X a
withWindowSet ((WindowSet -> Logger) -> Logger)
-> (WindowSet -> Logger) -> Logger
forall a b. (a -> b) -> a -> b
$ Maybe String -> Logger
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe String -> Logger)
-> (WindowSet -> Maybe String) -> WindowSet -> Logger
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String)
-> (WindowSet -> String) -> WindowSet -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WindowSet -> String
forall i l a s sd. StackSet i l a s sd -> i
W.currentTag

-- $format
-- Combine logger formatting functions to make your
-- 'XMonad.Hooks.DynamicLog.ppExtras' more colorful and readable.
-- (For convenience this module exports 'Control.Applicative.<$>' to
-- use instead of \'.\' or \'$\' in hard to read formatting lines.
-- For example:
--
-- > myLogHook = dynamicLogWithPP def {
-- >     -- skipped
-- >     , ppExtras = [lLoad, lTitle, logSp 3, wrapL "[" "]" $ date "%a %d %b"]
-- >     , ppOrder = \(ws,l,_,xs) -> [l,ws] ++ xs
-- >     }
-- >   where
-- >     -- lTitle = fixedWidthL AlignCenter "." 99 . dzenColorL "cornsilk3" "" . padL . shortenL 80 $ logTitle
-- >     -- or something like:
-- >     lTitle = fixedWidthL AlignCenter "." 99 <$> dzenColorL "cornsilk3" "" <$> padL . shortenL 80 $ logTitle
-- >
-- >     lLoad = dzenColorL "#6A5ACD" "" . wrapL loadIcon "   " . padL $ loadAvg
-- >     loadIcon = " ^i(/home/me/.dzen/icons/load.xbm)"
--
-- Note: When applying 'shortenL' or 'fixedWidthL' to logger strings
-- containing colors or other formatting commands, apply the formatting
-- /after/ the length adjustment, or include \"invisible\" characters
-- in the length specification, e.g. in the above \'^fg(cornsilk3)\' and
-- \'^fg()' yields 19 invisible and 80 visible characters.

-- | Use a string formatting function to edit a 'Logger' string.
-- For example, to create a tag function to prefix or label loggers,
-- as in \'tag: output\', use:
--
-- > tagL l = onLogger $ wrap (l ++ ": ") ""
-- >
-- >    tagL "bat" battery
-- >    tagL "load" loadAvg
--
-- If you already have a (String -> String) function you want to
-- apply to a logger:
--
-- > revL = onLogger trim
--
-- See formatting utility source code for more 'onLogger' usage examples.
onLogger :: (String -> String) -> Logger -> Logger
onLogger :: (String -> String) -> Logger -> Logger
onLogger = (Maybe String -> Maybe String) -> Logger -> Logger
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Maybe String -> Maybe String) -> Logger -> Logger)
-> ((String -> String) -> Maybe String -> Maybe String)
-> (String -> String)
-> Logger
-> Logger
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> String) -> Maybe String -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap

-- | Wrap a logger's output in delimiters, unless it is @X (Nothing)@
-- or @X (Just \"\")@. Some examples:
--
-- >    wrapL " | " " | " (date "%a %d %b") -- ' | Tue 19 Feb | '
-- >
-- >    wrapL "bat: " "" battery            -- ' bat: battery_logger_output'
wrapL :: String -> String -> Logger -> Logger
wrapL :: String -> String -> Logger -> Logger
wrapL String
l String
r = (String -> String) -> Logger -> Logger
onLogger ((String -> String) -> Logger -> Logger)
-> (String -> String) -> Logger -> Logger
forall a b. (a -> b) -> a -> b
$ String -> String -> String -> String
wrap String
l String
r

-- | Make a logger's output constant width by padding with the given string,
-- /even if the logger is/ @X (Nothing)@ /or/ @X (Just \"\")@. Useful to
-- reduce visual noise as a title logger shrinks and grows, to use a fixed
-- width for a logger that sometimes becomes Nothing, or even to create
-- fancy spacers or character based art effects.
--
-- It fills missing logger output with a repeated character like \".\",
-- \":\" or pattern, like \" -.-\". The cycling padding string is reversed on
-- the left of the logger output. This is mainly useful with AlignCenter.
fixedWidthL :: Align  -- ^ AlignCenter, AlignRight, or AlignLeft
            -> String -- ^ String to cycle to pad missing logger output
            -> Int    -- ^ Fixed length to output (including invisible formatting characters)
            -> Logger -> Logger
fixedWidthL :: Align -> String -> Int -> Logger -> Logger
fixedWidthL Align
a String
str Int
n Logger
logger = do
    Maybe String
mbl <- Logger
logger
    let l :: String
l = String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
"" Maybe String
mbl
    case Align
a of
       Align
AlignCenter -> String -> Logger
forall a. a -> X (Maybe a)
toL (Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
n (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String -> String
forall (t :: * -> *) a. Foldable t => t a -> String
padhalf String
l String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
l String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
cs)
       Align
AlignRight -> String -> Logger
forall a. a -> X (Maybe a)
toL (String -> String
forall a. [a] -> [a]
reverse (Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
n (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String -> String
forall a. [a] -> [a]
reverse String
l String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
cs))
       Align
_ -> String -> Logger
forall a. a -> X (Maybe a)
toL (Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
n (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String
l String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
cs)
  where
    toL :: a -> X (Maybe a)
toL = Maybe a -> X (Maybe a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe a -> X (Maybe a)) -> (a -> Maybe a) -> a -> X (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe a
forall a. a -> Maybe a
Just
    cs :: String
cs  = String -> String
forall a. [a] -> [a]
cycle String
str
    padhalf :: t a -> String
padhalf t a
x = String -> String
forall a. [a] -> [a]
reverse (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Int -> String -> String
forall a. Int -> [a] -> [a]
take ((Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
- t a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length t a
x) Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
2) String
cs

-- | Create a \"spacer\" logger, e.g. @logSp 3 -- loggerizes \'   \'@.
-- For more complex \"spacers\", use 'fixedWidthL' with @return Nothing@.
logSp :: Int -> Logger
logSp :: Int -> Logger
logSp Int
n = Maybe String -> Logger
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe String -> Logger)
-> (String -> Maybe String) -> String -> Logger
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe String
forall a. a -> Maybe a
Just (String -> Maybe String)
-> (String -> String) -> String -> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> String
forall a. Int -> [a] -> [a]
take Int
n (String -> Logger) -> String -> Logger
forall a b. (a -> b) -> a -> b
$ String -> String
forall a. [a] -> [a]
cycle String
" "

-- | Pad a logger's output with a leading and trailing space, unless it
-- is @X (Nothing)@ or @X (Just \"\")@.
padL :: Logger -> Logger
padL :: Logger -> Logger
padL = (String -> String) -> Logger -> Logger
onLogger String -> String
pad

-- | Limit a logger's length, adding \"...\" if truncated.
shortenL :: Int -> Logger -> Logger
shortenL :: Int -> Logger -> Logger
shortenL = (String -> String) -> Logger -> Logger
onLogger ((String -> String) -> Logger -> Logger)
-> (Int -> String -> String) -> Int -> Logger -> Logger
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String -> String
shorten

-- | Color a logger's output with dzen foreground and background colors.
--
-- >  dzenColorL "green" "#2A4C3F" battery
dzenColorL :: String -> String -> Logger -> Logger
dzenColorL :: String -> String -> Logger -> Logger
dzenColorL String
fg String
bg = (String -> String) -> Logger -> Logger
onLogger ((String -> String) -> Logger -> Logger)
-> (String -> String) -> Logger -> Logger
forall a b. (a -> b) -> a -> b
$ String -> String -> String -> String
dzenColor String
fg String
bg

-- | Color a logger's output with xmobar foreground and background colors.
--
-- >  xmobarColorL "#6A5ACD" "gray6" loadAverage
xmobarColorL :: String -> String -> Logger -> Logger
xmobarColorL :: String -> String -> Logger -> Logger
xmobarColorL String
fg String
bg = (String -> String) -> Logger -> Logger
onLogger ((String -> String) -> Logger -> Logger)
-> (String -> String) -> Logger -> Logger
forall a b. (a -> b) -> a -> b
$ String -> String -> String -> String
xmobarColor String
fg String
bg

-- todo
-- * dynamicLogXinerama logger? Or sorted onscreen Id's with "current" indicator?
-- is logCurrent really useful at all?
--
-- * ppVisible, etc. Resolve code dup. somehow. Refactor DynamicLog so can
-- be used for regular PP stuff /and/ loggers?
--
-- * fns for "ppExtras as a whole", combine loggers more nicely.
--
-- * parsers  to use with fixedWidthL to be smarter about invisible characters?