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

-- | A fast logging system
--   
--   A fast logging system for Haskell
@package fast-logger
@version 3.2.6

module System.Log.FastLogger.Types
type TimeFormat = ByteString

-- | Type aliaes for date format and formatted date.
type FormattedTime = ByteString

module System.Log.FastLogger.File

-- | The spec for logging files
data FileLogSpec
FileLogSpec :: FilePath -> Integer -> Int -> FileLogSpec
[log_file] :: FileLogSpec -> FilePath

-- | Max log file size (in bytes) before requiring rotation.
[log_file_size] :: FileLogSpec -> Integer

-- | Max number of rotated log files to keep around before overwriting the
--   oldest one.
[log_backup_number] :: FileLogSpec -> Int

-- | The spec for time based rotation. It supports post processing of log
--   files. Does not delete any logs. Example:
--   
--   
--   timeRotate fname = LogFileTimedRotate
--                  (TimedFileLogSpec fname timeFormat sametime compressFile)
--                  defaultBufSize
--      where
--          timeFormat = "%FT%H%M%S"
--          sametime = (==) on C8.takeWhile (/=T)
--          compressFile fp = void . forkIO $
--              callProcess "tar" [ "--remove-files", "-caf", fp <> ".gz", fp ]
--   
data TimedFileLogSpec
TimedFileLogSpec :: FilePath -> TimeFormat -> (FormattedTime -> FormattedTime -> Bool) -> (FilePath -> IO ()) -> TimedFileLogSpec

-- | base file path
[timed_log_file] :: TimedFileLogSpec -> FilePath

-- | time format to prepend
[timed_timefmt] :: TimedFileLogSpec -> TimeFormat

-- | function that compares two formatted times as specified by
--   timed_timefmt and decides if a new rotation is supposed to begin
[timed_same_timeframe] :: TimedFileLogSpec -> FormattedTime -> FormattedTime -> Bool

-- | processing function called asynchronously after a file is added to the
--   rotation
[timed_post_process] :: TimedFileLogSpec -> FilePath -> IO ()

-- | Checking if a log file can be written.
check :: FilePath -> IO ()

-- | Rotating log files.
rotate :: FileLogSpec -> IO ()

-- | Prefix file name with formatted time
prefixTime :: FormattedTime -> FilePath -> FilePath

-- | Formatting time is slow. This package provides mechanisms to cache
--   formatted date.
module System.Log.FastLogger.Date

-- | Make IO action which get cached formatted local time. Use this
--   to avoid the cost of frequently time formatting by caching an auto
--   updating formatted time, this cache update every 1 second. more detail
--   in Control.AutoUpdate
newTimeCache :: TimeFormat -> IO (IO FormattedTime)

-- | A simple time cache using format "%d%b%Y:%T %z"
simpleTimeFormat :: TimeFormat

-- | A simple time cache using format "%d-%b-%Y %T"
simpleTimeFormat' :: TimeFormat

module System.Log.FastLogger.LoggerSet

-- | A set of loggers. The number of loggers is the capabilities of GHC
--   RTS. You can specify it with "+RTS -N<x>". A buffer is prepared
--   for each capability.
data LoggerSet

-- | Creating a new LoggerSet using a file.
--   
--   Uses numCapabilties many buffers, which will result in log
--   output that is not ordered by time (see newFileLoggerSetN).
newFileLoggerSet :: BufSize -> FilePath -> IO LoggerSet

-- | Creating a new LoggerSet using a file, using only the given
--   number of capabilites.
--   
--   Giving mn = Just 1 scales less well on multi-core machines,
--   but provides time-ordered output.
newFileLoggerSetN :: BufSize -> Maybe Int -> FilePath -> IO LoggerSet

-- | Creating a new LoggerSet using stdout.
newStdoutLoggerSet :: BufSize -> IO LoggerSet

-- | Creating a new LoggerSet using stdout, with the given number of
--   buffers (see newFileLoggerSetN).
newStdoutLoggerSetN :: BufSize -> Maybe Int -> IO LoggerSet

-- | Creating a new LoggerSet using stderr.
newStderrLoggerSet :: BufSize -> IO LoggerSet

-- | Creating a new LoggerSet using stderr, with the given number of
--   buffers (see newFileLoggerSetN).
newStderrLoggerSetN :: BufSize -> Maybe Int -> IO LoggerSet

-- | Creating a new LoggerSet. If Nothing is specified to the
--   second argument, stdout is used. Please note that the minimum
--   BufSize is 1.

-- | Deprecated: Use newFileLoggerSet etc instead
newLoggerSet :: BufSize -> Maybe Int -> Maybe FilePath -> IO LoggerSet

-- | Creating a new LoggerSet using a FD.
newFDLoggerSet :: BufSize -> Maybe Int -> Maybe FilePath -> FD -> IO LoggerSet

-- | Renewing the internal file information in LoggerSet. This does
--   nothing for stdout and stderr.
renewLoggerSet :: LoggerSet -> IO ()

-- | Flushing the buffers, closing the internal file information and
--   freeing the buffers.
rmLoggerSet :: LoggerSet -> IO ()

-- | Writing a log message to the corresponding buffer. If the buffer
--   becomes full, the log messages in the buffer are written to its
--   corresponding file, stdout, or stderr.
pushLogStr :: LoggerSet -> LogStr -> IO ()

-- | Same as pushLogStr but also appends a newline.
pushLogStrLn :: LoggerSet -> LogStr -> IO ()

-- | Flushing log messages in buffers. This function must be called
--   explicitly when the program is being terminated.
--   
--   Note: Since version 2.1.6, this function does not need to be
--   explicitly called, as every push includes an auto-debounced flush
--   courtesy of the auto-update package. Since version 2.2.2, this
--   function can be used to force flushing outside of the debounced flush
--   calls.
flushLogStr :: LoggerSet -> IO ()

-- | Replacing the file path in LoggerSet and returning a new
--   LoggerSet and the old file path.
replaceLoggerSet :: LoggerSet -> FilePath -> (LoggerSet, Maybe FilePath)

-- | This module provides a fast logging system which scales on multicore
--   environments (i.e. +RTS -N<x>).
--   
--   Note: This library does not guarantee correct ordering of log messages
--   when program is run on more than one core thus users should rely more
--   on message timestamps than on their order in the log.
module System.Log.FastLogger

-- | FastLogger simply log logStr.
type FastLogger = LogStr -> IO ()
type LogType = LogType' LogStr

-- | Logger Type.
data LogType' a
[LogNone] :: LogType' LogStr
[LogStdout] :: BufSize -> LogType' LogStr
[LogStderr] :: BufSize -> LogType' LogStr
[LogFileNoRotate] :: FilePath -> BufSize -> LogType' LogStr
[LogFile] :: FileLogSpec -> BufSize -> LogType' LogStr
[LogFileTimedRotate] :: TimedFileLogSpec -> BufSize -> LogType' LogStr
[LogCallback] :: forall a. (a -> IO ()) -> IO () -> LogType' a

-- | Initialize a FastLogger without attaching timestamp a tuple of
--   logger and clean up action are returned. This type signature should be
--   read as:
--   
--   
--   newFastLogger :: LogType -> IO (FastLogger, IO ())
--   
--   
--   This logger uses numCapabilities many buffers, and thus does
--   not provide time-ordered output. For time-ordered output, use
--   newFastLogger1.
newFastLogger :: LogType' v -> IO (v -> IO (), IO ())

-- | Like newFastLogger, but creating a logger that uses only 1
--   internal builder. This scales less on multi-core machines and consumes
--   more memory because of an internal queue but provides time-ordered
--   output.
newFastLogger1 :: LogType' v -> IO (v -> IO (), IO ())

-- | bracket version of newFastLogger
withFastLogger :: LogType -> (FastLogger -> IO a) -> IO a

-- | TimedFastLogger pass FormattedTime to callback and
--   simply log its result. this can be used to customize how to log
--   timestamp.
--   
--   Usually, one would write a wrapper on top of TimedFastLogger,
--   for example:
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   log :: TimedFastLogger -> LogStr -> IO ()
--   log logger msg = logger (\time -> toLogStr (show time) <> " " <> msg <> "\n")
--   
type TimedFastLogger = FormattedTime -> LogStr -> IO ()

-- | Initialize a FastLogger with timestamp attached to each
--   message. a tuple of logger and clean up action are returned.
newTimedFastLogger :: IO FormattedTime -> LogType -> IO (TimedFastLogger, IO ())

-- | bracket version of newTimeFastLogger
withTimedFastLogger :: IO FormattedTime -> LogType -> (TimedFastLogger -> IO a) -> IO a

-- | Log message builder. Use (<>) to append two LogStr in
--   O(1).
data LogStr

-- | Types that can be converted to a LogStr. Instances for types
--   from the text library use a UTF-8 encoding. Instances for
--   numerical types use a decimal encoding.
class ToLogStr msg
toLogStr :: ToLogStr msg => msg -> LogStr

-- | Converting LogStr to ByteString.
fromLogStr :: LogStr -> ByteString

-- | Obtaining the length of LogStr.
logStrLength :: LogStr -> Int

-- | The type for buffer size of each core.
type BufSize = Int

-- | The default buffer size (4,096 bytes).
defaultBufSize :: BufSize

-- | The contents of this module can change at any time without warning.
module System.Log.FastLogger.Internal
type Buffer = Ptr Word8

-- | The type for buffer size of each core.
type BufSize = Int

-- | The default buffer size (4,096 bytes).
defaultBufSize :: BufSize
getBuffer :: BufSize -> IO Buffer
freeBuffer :: Buffer -> IO ()
toBufIOWith :: Buffer -> BufSize -> (Buffer -> Int -> IO ()) -> Builder -> IO ()
type FD = FD
closeFD :: FD -> IO ()
openFileFD :: FilePath -> IO FD
getStderrFD :: IO FD
getStdoutFD :: IO FD
writeRawBufferPtr2FD :: IORef FD -> Ptr Word8 -> Int -> IO Int
isFDValid :: FD -> Bool
invalidFD :: FD

-- | An associative operation.
--   
--   
Examples
--   
--   
--   >>> [1,2,3] <> [4,5,6]
--   [1,2,3,4,5,6]
--   
--   
--   
--   >>> Just [1, 2, 3] <> Just [4, 5, 6]
--   Just [1,2,3,4,5,6]
--   
--   
--   
--   >>> putStr "Hello, " <> putStrLn "World!"
--   Hello, World!
--   
(<>) :: Semigroup a => a -> a -> a
infixr 6 <>

-- | Identity of mappend
--   
--   
Examples
--   
--   
--   >>> "Hello world" <> mempty
--   "Hello world"
--   
--   
--   
--   >>> mempty <> [1, 2, 3]
--   [1,2,3]
--   
mempty :: Monoid a => a

-- | Builders denote sequences of bytes. They are Monoids
--   where mempty is the zero-length sequence and mappend is
--   concatenation, which runs in O(1).
data Builder

-- | Log message builder. Use (<>) to append two LogStr in
--   O(1).
data LogStr
LogStr :: !Int -> Builder -> LogStr

-- | Types that can be converted to a LogStr. Instances for types
--   from the text library use a UTF-8 encoding. Instances for
--   numerical types use a decimal encoding.
class ToLogStr msg
toLogStr :: ToLogStr msg => msg -> LogStr

-- | Converting LogStr to ByteString.
fromLogStr :: LogStr -> ByteString

-- | Obtaining the length of LogStr.
logStrLength :: LogStr -> Int

-- | A non-scale but time-ordered logger.
data SingleLogger

-- | Creating SingleLogger.
newSingleLogger :: BufSize -> IORef FD -> IO SingleLogger

-- | A scale but non-time-ordered logger.
data MultiLogger

-- | Creating MultiLogger. The first argument is the number of the
--   internal builders.
newMultiLogger :: Int -> BufSize -> IORef FD -> IO MultiLogger

-- | Writting LogStr using a buffer in blocking mode. The size of
--   LogStr must be smaller or equal to the size of buffer.
writeLogStr :: Buffer -> IORef FD -> LogStr -> IO ()

-- | Writting LogStr using a temporary buffer.
writeBigLogStr :: IORef FD -> LogStr -> IO ()

-- | A class for internal loggers.
class Loggers a
stopLoggers :: Loggers a => a -> IO ()
pushLog :: Loggers a => a -> LogStr -> IO ()
flushAllLog :: Loggers a => a -> IO ()
