Polymorphic and very general logging action type.
msgtype variables is an input for logger. It can be Text or custom logging messsage with different fields that you want to format in future.mtype variable is for monadic action inside which logging is happening. It can be either IO or some custom pure monad.
Key design point here is that LogAction is:
DivisibleDecidableComonad
Constructors
LogActionunLogAction :: msg -> m ()
Instances5Functor, Contravariant, Semigroup, Monoid, HasLog
UnrepresentableClass => Functor (LogAction m)Defined in co-log-core-0.3.2.2 · Colog.Core.Action⚠️CAUTION⚠️ This instance is for custom error display only.
LogAction is not supposed to have Functor instance by design.
In case it is used by mistake, the user will see the following:
Example1 expression fmap show logStringStdout...... 'LogAction' cannot have a 'Functor' instance by design. However, you've attempted to use this instance.... Probably you meant 'Contravariant' class instance with the following methods: * contramap :: (a -> b) -> LogAction m b -> LogAction m a * (>$) :: b -> LogAction m b -> LogAction m a...
# 207 "srcCologCore/Action.hs"
Contravariant (LogAction m)Defined in co-log-core-0.3.2.2 · Colog.Core.ActionApplicative m => Semigroup (LogAction m a)Defined in co-log-core-0.3.2.2 · Colog.Core.ActionThis instance allows you to join multiple logging actions into single one.
For example, if you have two actions like these:
logToStdout :: LogAction IO String -- outputs String to terminal logToFile :: LogAction IO String -- appends String to some fileYou can create new LogAction that perform both actions one after another using Semigroup:
logToBoth :: LogAction IO String -- outputs String to both terminal and some file logToBoth = logToStdout <> logToFileApplicative m => Monoid (LogAction m a)Defined in co-log-core-0.3.2.2 · Colog.Core.ActionHasLog (LogAction m msg) msg mDefined in co-log-core-0.3.2.2 · Colog.Core.Class