fast-logger-3.2.6: 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 Source #

type BufSize = Int Source #

The type for buffer size of each core.

defaultBufSize :: BufSize Source #

The default buffer size (4,096 bytes).

getBuffer :: BufSize -> IO Buffer Source #

freeBuffer :: Buffer -> IO () Source #

toBufIOWith :: Buffer -> BufSize -> (Buffer -> Int -> IO ()) -> Builder -> IO () Source #

type FD = FD Source #

closeFD :: FD -> IO () Source #

openFileFD :: FilePath -> IO FD Source #

getStderrFD :: IO FD Source #

getStdoutFD :: IO FD Source #

writeRawBufferPtr2FD :: IORef FD -> Ptr Word8 -> Int -> IO Int Source #

isFDValid :: FD -> Bool Source #

invalidFD :: FD Source #

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

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 Source #

Identity of `mappend`

#### Examples

Expand

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

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

data Builder Source #

`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 Source # |
Instance details Defined in System.Log.FastLogger.LogStr Methods toLogStr :: Builder -> LogStr Source #
Monoid Builder |
Instance details Defined in Data.ByteString.Builder.Internal Methods mempty :: Builder Source # mappend :: Builder -> Builder -> Builder Source # mconcat :: [Builder] -> Builder Source #
Semigroup Builder |
Instance details Defined in Data.ByteString.Builder.Internal Methods (<>) :: Builder -> Builder -> Builder Source # sconcat :: NonEmpty Builder -> Builder Source # stimes :: Integral b => b -> Builder -> Builder Source #
IsString Builder |
Instance details Defined in Data.ByteString.Builder Methods fromString :: String -> Builder Source #
IsList Builder | For long or infinite lists use `fromList` because it uses `LazyByteString` otherwise use `fromListN` which uses `StrictByteString`.

Instance details

Defined in Data.ByteString.Builder.Internal

Associated Types

type Item Builder |
Instance details Defined in Data.ByteString.Builder.Internal type Item Builder = Word8

Methods

fromList :: [Item Builder] -> Builder Source #

fromListN :: Int -> [Item Builder] -> Builder Source #

toList :: Builder -> [Item Builder] Source #

Show Builder | Since: bytestring-0.11.1.0
Instance details Defined in Data.ByteString.Builder Methods showsPrec :: Int -> Builder -> ShowS Source # show :: Builder -> String Source # showList :: [Builder] -> ShowS Source #
type Item Builder |
Instance details Defined in Data.ByteString.Builder.Internal type Item Builder = Word8

data LogStr Source #

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

Constructors

LogStr !Int Builder |

#### Instances

Instances details

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

class ToLogStr msg where Source #

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 Source #

#### Instances

Instances details

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

fromLogStr :: LogStr -> ByteString Source #

Converting `LogStr` to `ByteString`.

logStrLength :: LogStr -> Int Source #

Obtaining the length of `LogStr`.

data SingleLogger Source #

A non-scale but time-ordered logger.

#### Instances

Instances details

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

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

Creating `SingleLogger`.

data MultiLogger Source #

A scale but non-time-ordered logger.

#### Instances

Instances details

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

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

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

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

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 () Source #

Writting `LogStr` using a temporary buffer.

class Loggers a where Source #

A class for internal loggers.

Methods

stopLoggers :: a -> IO () Source #

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

flushAllLog :: a -> IO () Source #

#### Instances

Instances details

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

module System.Log.FastLogger.LoggerSet