distributed-process-extras-0.2.1.1: Cloud Haskell Extras

Copyright(c) Tim Watson 2013 - 2014
LicenseBSD3 (see the file LICENSE)
MaintainerTim Watson <watson.timothy@gmail.com>
Stabilityexperimental
Portabilitynon-portable (requires concurrency)
Safe HaskellNone
LanguageHaskell98

Control.Distributed.Process.Extras.SystemLog

Contents

Description

This module provides a general purpose logging facility, implemented as a distributed-process Management Agent. To start the logging agent on a running node, evaluate systemLog with the relevant expressions to handle logging textual messages, a cleanup operation (if required), initial log level and a formatting expression.

We export a working example in the form of systemLogFile, which logs to a text file using buffered I/O. Its implementation is very simple, and should serve as a demonstration of how to use the API:

systemLogFile :: FilePath -> LogLevel -> LogFormat -> Process ProcessId
systemLogFile path lvl fmt = do
  h <- liftIO $ openFile path AppendMode
  liftIO $ hSetBuffering h LineBuffering
  systemLog (liftIO . hPutStrLn h) (liftIO (hClose h)) lvl fmt

Synopsis

Types exposed by this module

type LogChan = () Source

data LogText Source

Constructors

LogText 

Fields

txt :: !String
 

Instances

class ToLog m where Source

Methods

toLog :: m -> Process (LogLevel -> LogMessage) Source

class Logger a where Source

Methods

logMessage :: a -> LogMessage -> Process () Source

Mx Agent Configuration / Startup

systemLog Source

Arguments

:: (String -> Process ())

This expression does the actual logging

-> Process ()

An expression used to clean up any residual state

-> LogLevel

The initial LogLevel to use

-> LogFormat

An expression used to format logging messages/text

-> Process ProcessId 

Start a system logger process as a management agent.

systemLogFile

systemLogFile :: FilePath -> LogLevel -> LogFormat -> Process ProcessId Source

Start a system logger that writes to a file.

This is a very basic file logging facility, that uses regular buffered file I/O (i.e., System.IO.hPutStrLn et al) under the covers. The handle is closed appropriately if/when the logging process terminates.

See Control.Distributed.Process.Management.mxAgentWithFinalize for futher details about management agents that use finalizers.

Logging Messages

report :: Logger l => (l -> LogText -> Process ()) -> l -> String -> Process () Source

debug :: (Logger l, ToLog m) => l -> m -> Process () Source

info :: (Logger l, ToLog m) => l -> m -> Process () Source

notice :: (Logger l, ToLog m) => l -> m -> Process () Source

warning :: (Logger l, ToLog m) => l -> m -> Process () Source

error :: (Logger l, ToLog m) => l -> m -> Process () Source

critical :: (Logger l, ToLog m) => l -> m -> Process () Source

alert :: (Logger l, ToLog m) => l -> m -> Process () Source

emergency :: (Logger l, ToLog m) => l -> m -> Process () Source

sendLog :: (Logger l, ToLog m) => l -> m -> LogLevel -> Process () Source