Copyright | (c) 2018-2020 Kowainik 2021-2025 Co-Log |
---|---|
License | MPL-2.0 |
Maintainer | Co-Log <xrom.xkov@gmail.com> |
Stability | Stable |
Portability | Portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Introduces logging actions working in MonadIO
. These actions are very basic
and inefficient because they use the String
data type. If you don't want to
have extra dependencies and performance of logging is not the bottleneck of your
application, then these functions should be enough. Otherwise use functions from
the Colog.Actions module from the co-log
package.
Synopsis
- logStringStdout :: MonadIO m => LogAction m String
- logStringStderr :: MonadIO m => LogAction m String
- logStringHandle :: MonadIO m => Handle -> LogAction m String
- withLogStringFile :: MonadIO m => FilePath -> (LogAction m String -> IO r) -> IO r
- logPrint :: forall a m. (Show a, MonadIO m) => LogAction m a
- logPrintStderr :: forall a m. (Show a, MonadIO m) => LogAction m a
- logPrintHandle :: forall a m. (Show a, MonadIO m) => Handle -> LogAction m a
- withLogPrintFile :: forall a m r. (Show a, MonadIO m) => FilePath -> (LogAction m a -> IO r) -> IO r
- liftLogIO :: MonadIO m => LogAction IO msg -> LogAction m msg
- logFlush :: MonadIO m => Handle -> LogAction m a
String
actions
logStringStdout :: MonadIO m => LogAction m String Source #
Action that prints String
to stdout.
This action does not flush the output buffer.
If buffering mode is block buffering, the effect of this action can be delayed.
>>>
logStringStdout <& "foo"
foo
logStringStderr :: MonadIO m => LogAction m String Source #
Action that prints String
to stderr.
This action does not flush the output buffer.
If buffering mode is block buffering, the effect of this action can be delayed.
>>>
logStringStderr <& "foo"
foo
withLogStringFile :: MonadIO m => FilePath -> (LogAction m String -> IO r) -> IO r Source #
Action that prints String
to file. Instead of returning LogAction
it's
implemented in continuation-passing style because it's more efficient to open
file only once at the start of the application and write to Handle
instead of
opening file each time we need to write to it.
Opens file in AppendMode
. Automatically flushes the output buffer.
>>>
logger action = action <& "foo"
>>>
withLogStringFile "/dev/stdout" logger
foo
Show
actions
logPrint :: forall a m. (Show a, MonadIO m) => LogAction m a Source #
Action that prints to stdout using Show
.
This action does not flush the output buffer.
If buffering mode is block buffering, the effect of this action can be delayed.
>>>
logPrint <& 5
5
logPrintStderr :: forall a m. (Show a, MonadIO m) => LogAction m a Source #
Action that prints to stderr using Show
.
This action does not flush the output buffer.
If buffering mode is block buffering, the effect of this action can be delayed.
>>>
logPrintStderr <& 5
5
withLogPrintFile :: forall a m r. (Show a, MonadIO m) => FilePath -> (LogAction m a -> IO r) -> IO r Source #
Action that prints to a file using Show
. See withLogStringFile
for details.