System.Log.FastLogger.Internal

fast-logger-3.2.5: A fast logging system

Safe Haskell | None
Language | Haskell2010

System.Log.FastLogger.Internal

Description

The contents of this module can change at any time without warning.

Synopsis

- type Buffer = Ptr Word8
- type BufSize = Int
- 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
- (<>) :: Semigroup a => a -> a -> a
- mempty :: Monoid a => a
- data Builder
- data LogStr = LogStr !Int Builder
- class ToLogStr msg where
  - toLogStr :: msg -> LogStr
- fromLogStr :: LogStr -> ByteString
- logStrLength :: LogStr -> Int
- data SingleLogger
- newSingleLogger :: BufSize -> IORef FD -> IO SingleLogger
- data MultiLogger
- newMultiLogger :: Int -> BufSize -> IORef FD -> IO MultiLogger
- writeLogStr :: Buffer -> IORef FD -> LogStr -> IO ()
- writeBigLogStr :: IORef FD -> LogStr -> IO ()
- class Loggers a where
  - stopLoggers :: a -> IO ()
  - pushLog :: a -> LogStr -> IO ()
  - flushAllLog :: a -> IO ()
- module System.Log.FastLogger.LoggerSet

# Documentation

type Buffer = Ptr Word8 #

type BufSize = Int #

The type for buffer size of each core.

defaultBufSize :: BufSize #

The default buffer size (4,096 bytes).

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 #

(<>) :: Semigroup a => a -> a -> a infixr 6 #

An associative operation.

#### Examples

Expand

    >>> [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!

mempty :: Monoid a => a #

Identity of `mappend`

#### Examples

Expand

    >>> "Hello world" <> mempty
    "Hello world"

    >>> mempty <> [1, 2, 3]
    [1,2,3]

data Builder #

`Builder`s denote sequences of bytes. They are `Monoid`s where `mempty` is the zero-length sequence and `mappend` is concatenation, which runs in O(1).

#### Instances

Instances details

ToLogStr Builder # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Builder -> LogStr #
Monoid Builder |
Instance details Defined in Data.ByteString.Builder.Internal Methods mempty :: Builder # mappend :: Builder -> Builder -> Builder # mconcat :: [Builder] -> Builder #
Semigroup Builder |
Instance details Defined in Data.ByteString.Builder.Internal Methods (<>) :: Builder -> Builder -> Builder # sconcat :: NonEmpty Builder -> Builder # stimes :: Integral b => b -> Builder -> Builder #

data LogStr #

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

Constructors

LogStr !Int Builder |

#### Instances

Instances details

ToLogStr LogStr # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: LogStr -> LogStr #
Monoid LogStr # |
Instance details Defined in System.Log.FastLogger.LogStr Methods mempty :: LogStr # mappend :: LogStr -> LogStr -> LogStr # mconcat :: [LogStr] -> LogStr #
Semigroup LogStr # |
Instance details Defined in System.Log.FastLogger.LogStr Methods (<>) :: LogStr -> LogStr -> LogStr # sconcat :: NonEmpty LogStr -> LogStr # stimes :: Integral b => b -> LogStr -> LogStr #
IsString LogStr # |
Instance details Defined in System.Log.FastLogger.LogStr Methods fromString :: String -> LogStr #
Show LogStr # |
Instance details Defined in System.Log.FastLogger.LogStr Methods showsPrec :: Int -> LogStr -> ShowS # show :: LogStr -> String # showList :: [LogStr] -> ShowS #
Eq LogStr # |
Instance details Defined in System.Log.FastLogger.LogStr Methods (==) :: LogStr -> LogStr -> Bool # (/=) :: LogStr -> LogStr -> Bool #

class ToLogStr msg where #

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.

Methods

toLogStr :: msg -> LogStr #

#### Instances

Instances details

ToLogStr Builder # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Builder -> LogStr #
ToLogStr ByteString # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: ByteString -> LogStr #
ToLogStr ByteString # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: ByteString -> LogStr #
ToLogStr ShortByteString # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: ShortByteString -> LogStr #
ToLogStr LogStr # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: LogStr -> LogStr #
ToLogStr Int16 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Int16 -> LogStr #
ToLogStr Int32 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Int32 -> LogStr #
ToLogStr Int64 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Int64 -> LogStr #
ToLogStr Int8 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Int8 -> LogStr #
ToLogStr Word16 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Word16 -> LogStr #
ToLogStr Word32 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Word32 -> LogStr #
ToLogStr Word64 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Word64 -> LogStr #
ToLogStr Word8 # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Word8 -> LogStr #
ToLogStr Text # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Text -> LogStr #
ToLogStr Text # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Text -> LogStr #
ToLogStr Integer # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Integer -> LogStr #
ToLogStr String # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: String -> LogStr #
ToLogStr Double # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Double -> LogStr #
ToLogStr Float # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Float -> LogStr #
ToLogStr Int # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Int -> LogStr #
ToLogStr Word # | Since: 2.4.14
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Word -> LogStr #

fromLogStr :: LogStr -> ByteString #

Converting `LogStr` to `ByteString`.

logStrLength :: LogStr -> Int #

Obtaining the length of `LogStr`.

data SingleLogger #

A non-scale but time-ordered logger.

#### Instances

Instances details

Loggers SingleLogger # |
Instance details Defined in System.Log.FastLogger.SingleLogger Methods stopLoggers :: SingleLogger -> IO () # pushLog :: SingleLogger -> LogStr -> IO () # flushAllLog :: SingleLogger -> IO () #

newSingleLogger :: BufSize -> IORef FD -> IO SingleLogger #

Creating `SingleLogger`.

data MultiLogger #

A scale but non-time-ordered logger.

#### Instances

Instances details

Loggers MultiLogger # |
Instance details Defined in System.Log.FastLogger.MultiLogger Methods stopLoggers :: MultiLogger -> IO () # pushLog :: MultiLogger -> LogStr -> IO () # flushAllLog :: MultiLogger -> IO () #

newMultiLogger :: Int -> BufSize -> IORef FD -> IO MultiLogger #

Creating `MultiLogger`. The first argument is the number of the internal builders.

writeLogStr :: Buffer -> IORef FD -> LogStr -> IO () #

Writting `LogStr` using a buffer in blocking mode. The size of `LogStr` must be smaller or equal to the size of buffer.

writeBigLogStr :: IORef FD -> LogStr -> IO () #

Writting `LogStr` using a temporary buffer.

class Loggers a where #

A class for internal loggers.

Methods

stopLoggers :: a -> IO () #

pushLog :: a -> LogStr -> IO () #

flushAllLog :: a -> IO () #

#### Instances

Instances details

Loggers MultiLogger # |
Instance details Defined in System.Log.FastLogger.MultiLogger Methods stopLoggers :: MultiLogger -> IO () # pushLog :: MultiLogger -> LogStr -> IO () # flushAllLog :: MultiLogger -> IO () #
Loggers SingleLogger # |
Instance details Defined in System.Log.FastLogger.SingleLogger Methods stopLoggers :: SingleLogger -> IO () # pushLog :: SingleLogger -> LogStr -> IO () # flushAllLog :: SingleLogger -> IO () #

module System.Log.FastLogger.LoggerSet