-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Simplistic logging using fast-logger.
--   
--   Trivial logger on top of fast-logger.
@package tinylog
@version 0.14.1


-- | <a>Msg</a> and <a>ToBytes</a> assist in constructing log messages. For
--   example:
--   
--   <pre>
--   &gt; g &lt;- new (setBufSize 1 . setOutput StdOut $ defSettings)
--   &gt; info g $ msg "some text" ~~ "key" .= "value" ~~ "okay" .= True
--   2014-04-28T21:18:20Z, I, some text, key=value, okay=True
--   &gt;
--   </pre>
module System.Logger.Message

-- | Convert some value to a <a>Builder</a>.
class ToBytes a
bytes :: ToBytes a => a -> Builder

-- | Type representing log messages.
data Msg
data Builder

-- | Turn some value into a <a>Msg</a>.
msg :: ToBytes a => a -> Msg -> Msg

-- | Render some field, i.e. a key-value pair delimited by "=".
field :: ToBytes a => ByteString -> a -> Msg -> Msg

-- | Alias of <a>field</a>.
(.=) :: ToBytes a => ByteString -> a -> Msg -> Msg
infixr 5 .=

-- | Concatenate two <a>ToBytes</a> values.
(+++) :: (ToBytes a, ToBytes b) => a -> b -> Builder
infixr 6 +++

-- | Alias of <a>.</a> with lowered precedence to allow combination with
--   <a>.=</a> without requiring parentheses.
(~~) :: (b -> c) -> (a -> b) -> a -> c
infixr 4 ~~

-- | Type restriction. Useful to disambiguate string literals when using
--   <tt>OverloadedStrings</tt> pragma.
val :: ByteString -> Builder
eval :: Builder -> ByteString

-- | Intersperse parts of the log message with the given delimiter and
--   render the whole builder into a <a>ByteString</a>.
--   
--   If the second parameter is set to <tt>True</tt>, netstrings encoding
--   is used for the message elements. Cf.
--   <a>http://cr.yp.to/proto/netstrings.txt</a> for details.
render :: ByteString -> Bool -> (Msg -> Msg) -> ByteString
instance Data.String.IsString System.Logger.Message.Builder
instance System.Logger.Message.ToBytes System.Logger.Message.Builder
instance System.Logger.Message.ToBytes Data.ByteString.Lazy.Internal.ByteString
instance System.Logger.Message.ToBytes Data.ByteString.Internal.ByteString
instance System.Logger.Message.ToBytes GHC.Types.Int
instance System.Logger.Message.ToBytes GHC.Int.Int8
instance System.Logger.Message.ToBytes GHC.Int.Int16
instance System.Logger.Message.ToBytes GHC.Int.Int32
instance System.Logger.Message.ToBytes GHC.Int.Int64
instance System.Logger.Message.ToBytes GHC.Integer.Type.Integer
instance System.Logger.Message.ToBytes GHC.Types.Word
instance System.Logger.Message.ToBytes GHC.Word.Word8
instance System.Logger.Message.ToBytes GHC.Word.Word16
instance System.Logger.Message.ToBytes GHC.Word.Word32
instance System.Logger.Message.ToBytes GHC.Word.Word64
instance System.Logger.Message.ToBytes GHC.Types.Float
instance System.Logger.Message.ToBytes GHC.Types.Double
instance System.Logger.Message.ToBytes Data.Text.Internal.Text
instance System.Logger.Message.ToBytes Data.Text.Internal.Lazy.Text
instance System.Logger.Message.ToBytes GHC.Types.Char
instance System.Logger.Message.ToBytes [GHC.Types.Char]
instance System.Logger.Message.ToBytes GHC.Types.Bool
instance GHC.Base.Semigroup System.Logger.Message.Builder
instance GHC.Base.Monoid System.Logger.Message.Builder


-- | Small layer on top of <tt>fast-logger</tt> which adds log-levels and
--   timestamp support and not much more.
module System.Logger
data Settings

-- | Default settings:
--   
--   <ul>
--   <li><a>logLevel</a> = <a>Debug</a></li>
--   <li><a>output</a> = <a>StdOut</a></li>
--   <li><a>format</a> = <a>iso8601UTC</a></li>
--   <li><a>delimiter</a> = ", "</li>
--   <li><a>netstrings</a> = False</li>
--   <li><a>bufSize</a> = <a>defaultBufSize</a></li>
--   <li><a>name</a> = Nothing</li>
--   </ul>
defSettings :: Settings
logLevel :: Settings -> Level
setLogLevel :: Level -> Settings -> Settings

-- | Log level of some named logger.
logLevelOf :: Text -> Settings -> Maybe Level

-- | Specify a log level for the given named logger. When a logger is
--   <tt>clone</tt>d and given a name, the <a>logLevel</a> of the cloned
--   logger will be the provided here.
setLogLevelOf :: Text -> Level -> Settings -> Settings
output :: Settings -> Output
setOutput :: Output -> Settings -> Settings

-- | The time and date format used for the timestamp part of a log line.
format :: Settings -> Maybe DateFormat
setFormat :: Maybe DateFormat -> Settings -> Settings

-- | Delimiter string which separates log line parts.
delimiter :: Settings -> ByteString
setDelimiter :: ByteString -> Settings -> Settings

-- | Whether to use <a>netstring</a> encoding for log lines.
netstrings :: Settings -> Bool
setNetStrings :: Bool -> Settings -> Settings
bufSize :: Settings -> Int
setBufSize :: Int -> Settings -> Settings
name :: Settings -> Maybe Text
setName :: Maybe Text -> Settings -> Settings
data Logger
data Level
Trace :: Level
Debug :: Level
Info :: Level
Warn :: Level
Error :: Level
Fatal :: Level
data Output
StdOut :: Output
StdErr :: Output
Path :: FilePath -> Output
newtype DateFormat
DateFormat :: UnixTime -> ByteString -> DateFormat
[display] :: DateFormat -> UnixTime -> ByteString

-- | ISO 8601 date-time format.
iso8601UTC :: DateFormat
new :: MonadIO m => Settings -> m Logger

-- | Invokes <a>new</a> with default settings and the given output as log
--   sink.
create :: MonadIO m => Output -> m Logger

-- | Inspect this logger's threshold.
level :: Logger -> Level

-- | Force buffered bytes to output sink.
flush :: MonadIO m => Logger -> m ()

-- | Closes the logger.
close :: MonadIO m => Logger -> m ()

-- | Clone the given logger and optionally give it a name (use
--   <tt>Nothing</tt> to clear).
--   
--   If <a>logLevelOf</a> returns a custom <a>Level</a> for this name then
--   the cloned logger will use it for its log messages.
clone :: Maybe Text -> Logger -> Logger
settings :: Logger -> Settings

-- | Logs a message with the given level if greater or equal to the
--   logger's threshold.
log :: MonadIO m => Logger -> Level -> (Msg -> Msg) -> m ()

-- | Abbreviation of <a>log</a> using the corresponding log level.
trace :: MonadIO m => Logger -> (Msg -> Msg) -> m ()

-- | Abbreviation of <a>log</a> using the corresponding log level.
debug :: MonadIO m => Logger -> (Msg -> Msg) -> m ()

-- | Abbreviation of <a>log</a> using the corresponding log level.
info :: MonadIO m => Logger -> (Msg -> Msg) -> m ()

-- | Abbreviation of <a>log</a> using the corresponding log level.
warn :: MonadIO m => Logger -> (Msg -> Msg) -> m ()

-- | Abbreviation of <a>log</a> using the corresponding log level.
err :: MonadIO m => Logger -> (Msg -> Msg) -> m ()

-- | Abbreviation of <a>log</a> using the corresponding log level.
fatal :: MonadIO m => Logger -> (Msg -> Msg) -> m ()


-- | The <a>MonadLogger</a> type-class and associated functions.
module System.Logger.Class
data Settings

-- | Default settings:
--   
--   <ul>
--   <li><a>logLevel</a> = <a>Debug</a></li>
--   <li><a>output</a> = <a>StdOut</a></li>
--   <li><a>format</a> = <a>iso8601UTC</a></li>
--   <li><a>delimiter</a> = ", "</li>
--   <li><a>netstrings</a> = False</li>
--   <li><a>bufSize</a> = <a>defaultBufSize</a></li>
--   <li><a>name</a> = Nothing</li>
--   </ul>
defSettings :: Settings
logLevel :: Settings -> Level
setLogLevel :: Level -> Settings -> Settings
output :: Settings -> Output
setOutput :: Output -> Settings -> Settings

-- | The time and date format used for the timestamp part of a log line.
format :: Settings -> Maybe DateFormat
setFormat :: Maybe DateFormat -> Settings -> Settings

-- | Delimiter string which separates log line parts.
delimiter :: Settings -> ByteString
setDelimiter :: ByteString -> Settings -> Settings

-- | Whether to use <a>netstring</a> encoding for log lines.
netstrings :: Settings -> Bool
setNetStrings :: Bool -> Settings -> Settings
bufSize :: Settings -> Int
setBufSize :: Int -> Settings -> Settings
name :: Settings -> Maybe Text
setName :: Maybe Text -> Settings -> Settings
data Level
Trace :: Level
Debug :: Level
Info :: Level
Warn :: Level
Error :: Level
Fatal :: Level
data Output
StdOut :: Output
StdErr :: Output
Path :: FilePath -> Output
data DateFormat

-- | ISO 8601 date-time format.
iso8601UTC :: DateFormat
data Logger
new :: MonadIO m => Settings -> m Logger

-- | Invokes <a>new</a> with default settings and the given output as log
--   sink.
create :: MonadIO m => Output -> m Logger

-- | Inspect this logger's threshold.
level :: Logger -> Level

-- | Force buffered bytes to output sink.
flush :: MonadIO m => Logger -> m ()

-- | Closes the logger.
close :: MonadIO m => Logger -> m ()

-- | Clone the given logger and optionally give it a name (use
--   <tt>Nothing</tt> to clear).
--   
--   If <a>logLevelOf</a> returns a custom <a>Level</a> for this name then
--   the cloned logger will use it for its log messages.
clone :: Maybe Text -> Logger -> Logger
settings :: Logger -> Settings
class Monad m => MonadLogger m
log :: MonadLogger m => Level -> (Msg -> Msg) -> m ()

-- | Abbreviation for <a>log</a> using the corresponding log level.
trace :: MonadLogger m => (Msg -> Msg) -> m ()

-- | Abbreviation for <a>log</a> using the corresponding log level.
debug :: MonadLogger m => (Msg -> Msg) -> m ()

-- | Abbreviation for <a>log</a> using the corresponding log level.
info :: MonadLogger m => (Msg -> Msg) -> m ()

-- | Abbreviation for <a>log</a> using the corresponding log level.
warn :: MonadLogger m => (Msg -> Msg) -> m ()

-- | Abbreviation for <a>log</a> using the corresponding log level.
err :: MonadLogger m => (Msg -> Msg) -> m ()

-- | Abbreviation for <a>log</a> using the corresponding log level.
fatal :: MonadLogger m => (Msg -> Msg) -> m ()
