Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Safe HaskellNone

Util.Log

Contents

Description

Functions for logging.

Log msgs are used to report everything from errors and debug msgs to status reports. They are collected in a central place that writes them to a file in a machine-readable serialized format.

Synopsis

Documentation

configure :: (State -> State) -> IO.IO State Source #

Configure the logging system by modifying its internal state. Return the old state so you can restore it later.

msgs

data Msg Source #

Constructors

Msg 

Fields

Instances
Eq Msg # 
Instance details

Defined in Util.Log

Methods

(==) :: Msg -> Msg -> Bool #

(/=) :: Msg -> Msg -> Bool #

Read.Read Msg # 
Instance details

Defined in Util.Log

Show Msg # 
Instance details

Defined in Util.Log

Methods

showsPrec :: Int -> Msg -> ShowS #

show :: Msg -> String #

showList :: [Msg] -> ShowS #

DeepSeq.NFData Msg # 
Instance details

Defined in Util.Log

Methods

rnf :: Msg -> () #

Pretty Msg # 
Instance details

Defined in Util.Log

Serialize.Serialize Msg # 
Instance details

Defined in Util.Log

data

with_dyn :: Typeable a => Text -> a -> Msg -> Msg Source #

other types

data Priority Source #

Constructors

Timer

Logs to determine where things are hanging when debugging a performance problem. Use LogView.ShowTimers to show the time elapsed between Timer logs.

Debug

Users don't look at this during normal use, but can be useful for debugging.

Notice

Informational msgs that the user might want to see. Progress messages in e.g. derivation and play status are included here.

Warn

Something went wrong in e.g. derivation. The user definitely wants to see this.

Error

Unexpected error in the app, which may quit. This is probably due to a bug.

Instances
Bounded Priority # 
Instance details

Defined in Util.Log

Enum Priority # 
Instance details

Defined in Util.Log

Eq Priority # 
Instance details

Defined in Util.Log

Ord Priority # 
Instance details

Defined in Util.Log

Read.Read Priority # 
Instance details

Defined in Util.Log

Show Priority # 
Instance details

Defined in Util.Log

Generics.Generic Priority # 
Instance details

Defined in Util.Log

Associated Types

type Generics.Rep Priority :: * -> * #

Aeson.Types.ToJSON Priority # 
Instance details

Defined in Util.Log

Aeson.Types.FromJSON Priority # 
Instance details

Defined in Util.Log

Serialize.Serialize Priority # 
Instance details

Defined in Util.Log

type Generics.Rep Priority # 
Instance details

Defined in Util.Log

data State Source #

Logging state. Don't log if a handle is Nothing.

Constructors

State 

write_json :: Handle -> Msg -> IO.IO () Source #

Write logs as JSON to the given handle.

write_formatted :: Handle -> Msg -> IO.IO () Source #

Write logs as human-readable text.

msg :: CallStack.Stack => Priority -> Maybe Stack.Stack -> Text -> Msg Source #

Create a msg without initializing it, so it doesn't have to be in LogMonad.

msg_call_stack :: CallStack -> Priority -> Maybe Stack.Stack -> Text -> Msg Source #

Like msg but when you already have a CallStack.

add_prefix :: Text -> Msg -> Msg Source #

Prefix a msg with the given string.

trace_logs :: [Msg] -> a -> a Source #

Write log msgs with trace, for debugging.

LogT monad

class Monad m => LogMonad m where Source #

Previously there was an initialize_msg method, which could use the LogMonad to fill in fields, e.g. add_time. Those things can happen in write too, but the msg could be created in a different context from the call to write. In practice, though, I don't do that very much, and when I did it was usually because I wasn't in a LogMonad at all, so I used the pure msg function.

Minimal complete definition

write

Methods

write :: Msg -> m () Source #

Instances
LogMonad IO.IO # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> IO.IO () Source #

LogMonad Deriver # 
Instance details

Defined in Derive.Deriver.Monad

Methods

write :: Msg -> Deriver () Source #

Monad m => LogMonad (LogT m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> LogT m () Source #

Monad m => LogMonad (UiLogT m) # 
Instance details

Defined in Ui.UiLog

Methods

write :: Msg -> UiLogT m () Source #

Monad m => LogMonad (CmdT m) #

Give CmdT unlifted access to all the logging functions.

Instance details

Defined in Cmd.Cmd

Methods

write :: Msg -> CmdT m () Source #

(Monoid w, LogMonad m) => LogMonad (WriterT w m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> WriterT w m () Source #

LogMonad m => LogMonad (StateT s m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> StateT s m () Source #

LogMonad m => LogMonad (StateT s m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> StateT s m () Source #

LogMonad m => LogMonad (ExceptT e m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> ExceptT e m () Source #

(Error e, LogMonad m) => LogMonad (ErrorT e m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> ErrorT e m () Source #

LogMonad m => LogMonad (ReaderT r m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> ReaderT r m () Source #

data LogT m a Source #

Instances
MonadTrans LogT # 
Instance details

Defined in Util.Log

Methods

lift :: Monad m => m a -> LogT m a #

MonadState st m => MonadState st (LogT m) # 
Instance details

Defined in Util.Log

Methods

get :: LogT m st #

put :: st -> LogT m () #

state :: (st -> (a, st)) -> LogT m a #

MonadReader r m => MonadReader r (LogT m) # 
Instance details

Defined in Util.Log

Methods

ask :: LogT m r #

local :: (r -> r) -> LogT m a -> LogT m a #

reader :: (r -> a) -> LogT m a #

MonadError e m => MonadError e (LogT m) # 
Instance details

Defined in Util.Log

Methods

throwError :: e -> LogT m a #

catchError :: LogT m a -> (e -> LogT m a) -> LogT m a #

Monad m => Monad (LogT m) # 
Instance details

Defined in Util.Log

Methods

(>>=) :: LogT m a -> (a -> LogT m b) -> LogT m b #

(>>) :: LogT m a -> LogT m b -> LogT m b #

return :: a -> LogT m a #

fail :: String -> LogT m a #

Functor m => Functor (LogT m) # 
Instance details

Defined in Util.Log

Methods

fmap :: (a -> b) -> LogT m a -> LogT m b #

(<$) :: a -> LogT m b -> LogT m a #

Monad m => Applicative.Applicative (LogT m) # 
Instance details

Defined in Util.Log

Methods

pure :: a -> LogT m a #

(<*>) :: LogT m (a -> b) -> LogT m a -> LogT m b #

liftA2 :: (a -> b -> c) -> LogT m a -> LogT m b -> LogT m c #

(*>) :: LogT m a -> LogT m b -> LogT m b #

(<*) :: LogT m a -> LogT m b -> LogT m a #

MonadIO m => MonadIO (LogT m) # 
Instance details

Defined in Util.Log

Methods

liftIO :: IO.IO a -> LogT m a #

Monad m => LogMonad (LogT m) # 
Instance details

Defined in Util.Log

Methods

write :: Msg -> LogT m () Source #

Monad m => LogMonad (UiLogT m) # 
Instance details

Defined in Ui.UiLog

Methods

write :: Msg -> UiLogT m () Source #

run :: Monad m => LogT m a -> m (a, [Msg]) Source #

run_id :: LogId a -> (a, [Msg]) Source #

format_msg :: Msg -> Text Source #

Format a msg in a nice user readable way.

serialize :: Msg -> ByteString.Lazy.ByteString Source #

Serialize a log msg. Newline separated text is nice because it's human readable and can use newlines for records. Previously I used Show, which is bulky and slow. JSON is hopefully faster, and retains the benefits of Show.